A free open source IT asset/license management system
Allow API token expiration in years to be configured via env
snipe5abfbdd1d222
diff --git a/.env.example b/.env.exampleindex 4608c185b2..6e41e009df 100644--- a/.env.example+++ b/.env.example@@ -76,6 +76,7 @@ ENCRYPT=falseCOOKIE_NAME=snipeit_sessionCOOKIE_DOMAIN=nullSECURE_COOKIES=false+API_TOKEN_EXPIRATION_YEARS=40# --------------------------------------------# OPTIONAL: SECURITY HEADER SETTINGSdiff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.phpindex efdbec0c08..067af8ccb0 100644--- a/app/Providers/AuthServiceProvider.php+++ b/app/Providers/AuthServiceProvider.php@@ -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();diff --git a/config/passport.php b/config/passport.phpindex 1d9244514a..b8342a6b59 100644--- a/config/passport.php+++ b/config/passport.php@@ -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),];\ No newline at end of file