Allow API token expiration in years to be configured via env

This commit is contained in:
snipe 2020-11-09 22:52:55 -08:00
parent 33dca84ec7
commit 5abfbdd1d2
3 changed files with 5 additions and 3 deletions

View file

@ -76,6 +76,7 @@ ENCRYPT=false
COOKIE_NAME=snipeit_session
COOKIE_DOMAIN=null
SECURE_COOKIES=false
API_TOKEN_EXPIRATION_YEARS=40
# --------------------------------------------
# OPTIONAL: SECURITY HEADER SETTINGS

View file

@ -87,9 +87,9 @@ class AuthServiceProvider extends ServiceProvider
$this->registerPolicies();
Passport::routes();
Passport::tokensExpireIn(Carbon::now()->addYears(20));
Passport::refreshTokensExpireIn(Carbon::now()->addYears(20));
Passport::personalAccessTokensExpireIn(Carbon::now()->addYears(20));
Passport::tokensExpireIn(Carbon::now()->addYears(config('passport.expiration_years')));
Passport::refreshTokensExpireIn(Carbon::now()->addYears(config('passport.expiration_years')));
Passport::personalAccessTokensExpireIn(Carbon::now()->addYears(config('passport.expiration_years')));
Passport::withCookieSerialization();

View file

@ -12,4 +12,5 @@ return [
*/
'private_key' => env('PASSPORT_PRIVATE_KEY'),
'public_key' => env('PASSPORT_PUBLIC_KEY'),
'expiration_years' => env('API_TOKEN_EXPIRATION_YEARS', 20),
];