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\Guards\OpenIdSessionGuard;
11 use BookStack\Auth\Access\LdapService;
12 use BookStack\Auth\Access\OpenIdService;
13 use BookStack\Auth\Access\RegistrationService;
14 use BookStack\Auth\UserRepo;
15 use Illuminate\Support\ServiceProvider;
17 class AuthServiceProvider extends ServiceProvider
20 * Bootstrap the application services.
24 public function boot()
26 Auth::extend('api-token', function ($app, $name, array $config) {
27 return new ApiTokenGuard($app['request']);
30 Auth::extend('ldap-session', function ($app, $name, array $config) {
31 $provider = Auth::createUserProvider($config['provider']);
32 return new LdapSessionGuard(
35 $this->app['session.store'],
36 $app[LdapService::class],
37 $app[RegistrationService::class]
41 Auth::extend('saml2-session', function ($app, $name, array $config) {
42 $provider = Auth::createUserProvider($config['provider']);
43 return new Saml2SessionGuard(
46 $this->app['session.store'],
47 $app[RegistrationService::class]
51 Auth::extend('openid-session', function ($app, $name, array $config) {
52 $provider = Auth::createUserProvider($config['provider']);
53 return new OpenIdSessionGuard(
56 $this->app['session.store'],
57 $app[OpenIdService::class],
58 $app[RegistrationService::class]
64 * Register the application services.
68 public function register()
70 Auth::provider('external-users', function ($app, array $config) {
71 return new ExternalBaseUserProvider($config['model']);