Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/AuthServiceProvider.php
Show All 9 Lines | |||||
class AuthServiceProvider extends ServiceProvider | class AuthServiceProvider extends ServiceProvider | ||||
{ | { | ||||
/** | /** | ||||
* The policy mappings for the application. | * The policy mappings for the application. | ||||
* | * | ||||
* @var array<class-string, class-string> | * @var array<class-string, class-string> | ||||
*/ | */ | ||||
protected $policies = [ | protected $policies = [ | ||||
// 'App\Model' => 'App\Policies\ModelPolicy', | |||||
]; | ]; | ||||
/** | /** | ||||
* Register any authentication / authorization services. | * Register any authentication / authorization services. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function boot() | public function boot() | ||||
{ | { | ||||
$this->registerPolicies(); | $this->registerPolicies(); | ||||
// Hashes all secrets and thus makes them non-recoverable | |||||
/* Passport::hashClientSecrets(); */ | |||||
// Only enable routes for access tokens | |||||
Passport::routes( | |||||
function ($router) { | |||||
$router->forAccessTokens(); | |||||
// Override the default route to avoid rate-limiting. | |||||
Route::post('/token', [ | |||||
'uses' => 'AccessTokenController@issueToken', | |||||
'as' => 'passport.token', | |||||
]); | |||||
} | |||||
); | |||||
Passport::tokensCan([ | Passport::tokensCan([ | ||||
mollekopf: Maybe this should go to the PassportServiceProvider? | |||||
'api' => 'Access API', | 'api' => 'Access API', | ||||
'mfa' => 'Access MFA API', | 'mfa' => 'Access MFA API', | ||||
]); | ]); | ||||
Passport::tokensExpireIn(now()->addMinutes(\config('auth.token_expiry_minutes'))); | Passport::tokensExpireIn(now()->addMinutes(\config('auth.token_expiry_minutes'))); | ||||
Passport::refreshTokensExpireIn(now()->addMinutes(\config('auth.refresh_token_expiry_minutes'))); | Passport::refreshTokensExpireIn(now()->addMinutes(\config('auth.refresh_token_expiry_minutes'))); | ||||
Passport::personalAccessTokensExpireIn(now()->addMonths(6)); | Passport::personalAccessTokensExpireIn(now()->addMonths(6)); | ||||
Passport::useClientModel(\App\Auth\PassportClient::class); | Passport::useClientModel(\App\Auth\PassportClient::class); | ||||
Passport::tokenModel()::observe(\App\Observers\Passport\TokenObserver::class); | Passport::tokenModel()::observe(\App\Observers\Passport\TokenObserver::class); | ||||
} | } | ||||
} | } |
Maybe this should go to the PassportServiceProvider?