3 namespace BookStack\Providers;
5 use BookStack\Api\ApiTokenGuard;
6 use BookStack\Auth\Access\ExternalBaseUserProvider;
7 use BookStack\Auth\Access\Guards\LdapSessionGuard;
8 use BookStack\Auth\Access\Guards\Saml2SessionGuard;
9 use BookStack\Auth\Access\Guards\OpenIdSessionGuard;
10 use BookStack\Auth\Access\LdapService;
11 use BookStack\Auth\Access\LoginService;
12 use BookStack\Auth\Access\OpenIdService;
13 use BookStack\Auth\Access\RegistrationService;
14 use Illuminate\Support\Facades\Auth;
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'], $app->make(LoginService::class));
30 Auth::extend('ldap-session', function ($app, $name, array $config) {
31 $provider = Auth::createUserProvider($config['provider']);
33 return new LdapSessionGuard(
36 $app['session.store'],
37 $app[LdapService::class],
38 $app[RegistrationService::class]
42 Auth::extend('saml2-session', function ($app, $name, array $config) {
43 $provider = Auth::createUserProvider($config['provider']);
45 return new Saml2SessionGuard(
48 $app['session.store'],
49 $app[RegistrationService::class]
53 Auth::extend('openid-session', function ($app, $name, array $config) {
54 $provider = Auth::createUserProvider($config['provider']);
55 return new OpenIdSessionGuard(
58 $this->app['session.store'],
59 $app[OpenIdService::class],
60 $app[RegistrationService::class]
66 * Register the application services.
70 public function register()
72 Auth::provider('external-users', function ($app, array $config) {
73 return new ExternalBaseUserProvider($config['model']);