2016-01-09 14:23:35 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Providers;
|
|
|
|
|
|
|
|
use Auth;
|
2019-12-30 09:51:28 -05:00
|
|
|
use BookStack\Api\ApiTokenGuard;
|
2020-02-01 06:42:22 -05:00
|
|
|
use BookStack\Auth\Access\ExternalBaseUserProvider;
|
|
|
|
use BookStack\Auth\Access\Guards\LdapSessionGuard;
|
2020-02-02 05:59:03 -05:00
|
|
|
use BookStack\Auth\Access\Guards\Saml2SessionGuard;
|
2020-07-01 17:27:50 -04:00
|
|
|
use BookStack\Auth\Access\Guards\OpenIdSessionGuard;
|
2018-09-25 07:30:50 -04:00
|
|
|
use BookStack\Auth\Access\LdapService;
|
2020-07-09 12:00:16 -04:00
|
|
|
use BookStack\Auth\Access\OpenIdService;
|
2020-02-02 12:31:00 -05:00
|
|
|
use BookStack\Auth\Access\RegistrationService;
|
2020-02-01 06:42:22 -05:00
|
|
|
use BookStack\Auth\UserRepo;
|
2016-01-09 14:23:35 -05:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap the application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2019-12-30 09:51:28 -05:00
|
|
|
Auth::extend('api-token', function ($app, $name, array $config) {
|
|
|
|
return new ApiTokenGuard($app['request']);
|
|
|
|
});
|
2020-02-01 06:42:22 -05:00
|
|
|
|
|
|
|
Auth::extend('ldap-session', function ($app, $name, array $config) {
|
|
|
|
$provider = Auth::createUserProvider($config['provider']);
|
|
|
|
return new LdapSessionGuard(
|
|
|
|
$name,
|
|
|
|
$provider,
|
|
|
|
$this->app['session.store'],
|
|
|
|
$app[LdapService::class],
|
2020-02-02 12:31:00 -05:00
|
|
|
$app[RegistrationService::class]
|
2020-02-01 06:42:22 -05:00
|
|
|
);
|
|
|
|
});
|
2020-02-02 05:59:03 -05:00
|
|
|
|
|
|
|
Auth::extend('saml2-session', function ($app, $name, array $config) {
|
|
|
|
$provider = Auth::createUserProvider($config['provider']);
|
|
|
|
return new Saml2SessionGuard(
|
|
|
|
$name,
|
|
|
|
$provider,
|
|
|
|
$this->app['session.store'],
|
2020-02-02 12:31:00 -05:00
|
|
|
$app[RegistrationService::class]
|
2020-02-02 05:59:03 -05:00
|
|
|
);
|
|
|
|
});
|
2020-07-01 17:27:50 -04:00
|
|
|
|
|
|
|
Auth::extend('openid-session', function ($app, $name, array $config) {
|
|
|
|
$provider = Auth::createUserProvider($config['provider']);
|
|
|
|
return new OpenIdSessionGuard(
|
|
|
|
$name,
|
|
|
|
$provider,
|
|
|
|
$this->app['session.store'],
|
2020-07-09 12:00:16 -04:00
|
|
|
$app[OpenIdService::class],
|
2020-07-01 17:27:50 -04:00
|
|
|
$app[RegistrationService::class]
|
|
|
|
);
|
|
|
|
});
|
2016-01-09 14:23:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2020-02-01 06:42:22 -05:00
|
|
|
Auth::provider('external-users', function ($app, array $config) {
|
|
|
|
return new ExternalBaseUserProvider($config['model']);
|
2016-01-09 14:23:35 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|