3 namespace BookStack\Providers;
6 use BookStack\Api\ApiTokenGuard;
7 use BookStack\Auth\Access\ExternalBaseUserProvider;
8 use BookStack\Auth\Access\Guards\LdapSessionGuard;
9 use BookStack\Auth\Access\Guards\Saml2SessionGuard;
10 use BookStack\Auth\Access\LdapService;
11 use BookStack\Auth\Access\RegistrationService;
12 use BookStack\Auth\UserRepo;
13 use Illuminate\Support\ServiceProvider;
15 class AuthServiceProvider extends ServiceProvider
18 * Bootstrap the application services.
22 public function boot()
24 Auth::extend('api-token', function ($app, $name, array $config) {
25 return new ApiTokenGuard($app['request']);
28 Auth::extend('ldap-session', function ($app, $name, array $config) {
29 $provider = Auth::createUserProvider($config['provider']);
30 return new LdapSessionGuard(
33 $this->app['session.store'],
34 $app[LdapService::class],
35 $app[RegistrationService::class]
39 Auth::extend('saml2-session', function ($app, $name, array $config) {
40 $provider = Auth::createUserProvider($config['provider']);
41 return new Saml2SessionGuard(
44 $this->app['session.store'],
45 $app[RegistrationService::class]
51 * Register the application services.
55 public function register()
57 Auth::provider('external-users', function ($app, array $config) {
58 return new ExternalBaseUserProvider($config['model']);