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\RegistrationService;
13 use BookStack\Auth\UserRepo;
14 use Illuminate\Support\ServiceProvider;
16 class AuthServiceProvider extends ServiceProvider
19 * Bootstrap the application services.
23 public function boot()
25 Auth::extend('api-token', function ($app, $name, array $config) {
26 return new ApiTokenGuard($app['request']);
29 Auth::extend('ldap-session', function ($app, $name, array $config) {
30 $provider = Auth::createUserProvider($config['provider']);
31 return new LdapSessionGuard(
34 $this->app['session.store'],
35 $app[LdapService::class],
36 $app[RegistrationService::class]
40 Auth::extend('saml2-session', function ($app, $name, array $config) {
41 $provider = Auth::createUserProvider($config['provider']);
42 return new Saml2SessionGuard(
45 $this->app['session.store'],
46 $app[RegistrationService::class]
50 Auth::extend('openid-session', function ($app, $name, array $config) {
51 $provider = Auth::createUserProvider($config['provider']);
52 return new OpenIdSessionGuard(
55 $this->app['session.store'],
56 $app[RegistrationService::class]
62 * Register the application services.
66 public function register()
68 Auth::provider('external-users', function ($app, array $config) {
69 return new ExternalBaseUserProvider($config['model']);