If TTL is set to null by any means (config file, setTTL on guard), the Factory will remove the exp claim from the payload as expected.
However, the exp payload is required in the PayloadValidator, so the generated payload doesn't pass validation.
| Q | A
| ----------------- | ---
| Bug? | yes
| New Feature? | no
| Framework | Laravel
| Framework version | 5.6.5
| Package version | 1.0.0-rc.2
| PHP version | 7.1.9
guard()->setTTL(null)->attempt($credentials)
I would expect the PayloadValidator to still consider the payload valid in this case.
The PayloadValidator raises an error.
Did you disable this:
'required_claims' => [
'iss',
'iat',
// 'exp', // Enable this when using ttl
'nbf',
'sub',
'jti',
],
in the config/jwt.php file?
@johankladder I didn't, I'm using Lumen and hadn't created the config file.
This does suggest that I should be able to load the PayloadValidator singleton and call setRequiredClaims, which should fix my issue.
Feel free to close this.
However, I still think that a TTL of null should disable the exp claim in the PayloadValidator.
You can set JWT_TTL to null + comment exp in required_claims
JWT_TTL=null
You can set JWT_TTL to null + comment
expin required_claims
I did this, but on creating token with custom claim it throws "Token has expired" error
vendor/tymon/jwt-auth/src/Validators/PayloadValidator.php:
if (Utils::timestamp($payload['exp'])->isPast()) {
throw new TokenExpiredException('Token has expired');
}
That worked for me to set infinite time in Laravel 5..8 , change in config > jwt.php
// 'ttl' => env('JWT_TTL', 60),
'ttl' => env('JWT_TTL', null),
and
// 'required_claims' => [ 'iss', 'iat', 'nbf', 'sub', 'jti', 'exp', ],
'required_claims' => [ 'iss', 'iat', 'nbf', 'sub', 'jti', ],
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Most helpful comment
@johankladder I didn't, I'm using Lumen and hadn't created the config file.
This does suggest that I should be able to load the
PayloadValidatorsingleton and callsetRequiredClaims, which should fix my issue.Feel free to close this.
However, I still think that a TTL of null should disable the
expclaim in thePayloadValidator.