leaf icon indicating copy to clipboard operation
leaf copied to clipboard

JWT Expiration Issue Sets 55 Years Instead of 1 Year

Open Muhsen-Dev opened this issue 9 months ago • 1 comments

Describe the bug

When setting the JWT token lifetime in LeafPHP, the expiration (exp) timestamp is set incorrectly. Instead of expiring 1 year from issuance, the token expiration is set 55 years into the future.

To Reproduce

1- JWT lifetime in config/auth.php:

'token.lifetime' => 60 * 60 * 24 * 365, // 1 year in seconds

2- Generate a JWT token using Leaf Auth: $success = auth()->register([ 'username' => 'example', 'email' => '[email protected]', 'password' => 'password' ]);

$token = auth()->data(); return response()->json($token);

3 - Decode the JWT token and observe the exp field: { "iat": 1743105385, "exp": 3486297170, // Should be ~1 year ahead, but it's 55 years ahead "iss": "localhost:5500" }

Expected behavior

{ "iat": 1743105385, "exp": 1774641385 "iss": "localhost:5500" }

Muhsen-Dev avatar Mar 27 '25 21:03 Muhsen-Dev

Hi @Muhsen-Dev can you pls run composer require leafs/date and see if that fixes the issue?

mychidarko avatar Apr 04 '25 11:04 mychidarko