You can override the global ttl (Time To Live) defined in config/jwt.php by setting a specific ttl value within individual guard configurations in config/auth.php.
- Custom TTL: Set an integer (e.g., minutes) to define a specific expiration for that guard.
- No Expiration: Set
ttl to null to ensure tokens for that guard never automatically expire. - Default TTL: If the
ttl key is omitted from the guard configuration, the guard will fall back to the global ttl value defined in config/jwt.php.
'guards' => [
'customers' => [
'driver' => 'jwt',
'provider' => 'customers',
'ttl' => env('JWT_CUSTOMERS_TTL', 15), // Custom TTL for 'customers' guard (15 minutes)
],
'administrators' => [
'driver' => 'jwt',
'provider' => 'administrators',
'ttl' => null, // 'administrators' guard has no expiration
],
// if no 'ttl' is set, it will use the 'ttl' value in `config/jwt.php`
'users' => [
'driver' => 'jwt',
'provider' => 'users',
],
],