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\UserRepo;
12 use Illuminate\Support\ServiceProvider;
14 class AuthServiceProvider extends ServiceProvider
17 * Bootstrap the application services.
21 public function boot()
23 Auth::extend('api-token', function ($app, $name, array $config) {
24 return new ApiTokenGuard($app['request']);
27 Auth::extend('ldap-session', function ($app, $name, array $config) {
28 $provider = Auth::createUserProvider($config['provider']);
29 return new LdapSessionGuard(
32 $this->app['session.store'],
33 $app[LdapService::class],
38 Auth::extend('saml2-session', function ($app, $name, array $config) {
39 $provider = Auth::createUserProvider($config['provider']);
40 return new Saml2SessionGuard(
43 $this->app['session.store'],
50 * Register the application services.
54 public function register()
56 Auth::provider('external-users', function ($app, array $config) {
57 return new ExternalBaseUserProvider($config['model']);