2016-01-10 03:23:35 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Providers;
|
|
|
|
|
|
|
|
use Auth;
|
2019-12-30 22:51:28 +08:00
|
|
|
use BookStack\Api\ApiTokenGuard;
|
2018-09-25 19:30:50 +08:00
|
|
|
use BookStack\Auth\Access\LdapService;
|
2016-01-10 03:23:35 +08:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap the application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2019-12-30 22:51:28 +08:00
|
|
|
Auth::extend('api-token', function ($app, $name, array $config) {
|
|
|
|
return new ApiTokenGuard($app['request']);
|
|
|
|
});
|
2016-01-10 03:23:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2018-01-29 00:58:52 +08:00
|
|
|
Auth::provider('ldap', function ($app, array $config) {
|
2016-05-02 04:20:50 +08:00
|
|
|
return new LdapUserProvider($config['model'], $app[LdapService::class]);
|
2016-01-10 03:23:35 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|