Merge pull request #2400 from delthas/feature-tokens-days

Add support for configurable OAuth tokens and refresh tokens lifetime
This commit is contained in:
daniel 2020-11-21 20:22:35 -07:00 committed by GitHub
commit 93a76b3c05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -28,8 +28,8 @@ class AuthServiceProvider extends ServiceProvider
if(config('pixelfed.oauth_enabled')) { if(config('pixelfed.oauth_enabled')) {
Passport::routes(null, ['middleware' => ['twofactor', \Fruitcake\Cors\HandleCors::class]]); Passport::routes(null, ['middleware' => ['twofactor', \Fruitcake\Cors\HandleCors::class]]);
Passport::tokensExpireIn(now()->addDays(15)); Passport::tokensExpireIn(now()->addDays(config('instance.oauth.token_expiration')));
Passport::refreshTokensExpireIn(now()->addDays(30)); Passport::refreshTokensExpireIn(now()->addDays(config('instance.oauth.refresh_expiration')));
Passport::enableImplicitGrant(); Passport::enableImplicitGrant();
if(config('instance.oauth.pat.enabled')) { if(config('instance.oauth.pat.enabled')) {
Passport::personalAccessClientId(config('instance.oauth.pat.id')); Passport::personalAccessClientId(config('instance.oauth.pat.id'));

View file

@ -55,6 +55,8 @@ return [
], ],
'oauth' => [ 'oauth' => [
'token_expiration' => env('OAUTH_TOKEN_DAYS', 15),
'refresh_expiration' => env('OAUTH_REFRESH_DAYS', 30),
'pat' => [ 'pat' => [
'enabled' => env('OAUTH_PAT_ENABLED', false), 'enabled' => env('OAUTH_PAT_ENABLED', false),
'id' => env('OAUTH_PAT_ID'), 'id' => env('OAUTH_PAT_ID'),