jean553
jean553

Reputation: 733

Symfony 4 - Lexik/JwtAuthenticationBundle - Cannot change token_ttl default value

I try to change the value of the token_ttl limit into the lexik_jwt_authentication.yaml file, but no matter the value I set, the generated token always has a 3600 seconds TTL. I also set the parameters secret_key and public_key and they are interpreted correctly.

The content of my lexik_jwt_authentication.yaml is:

lexik_jwt_authentication:
    secret_key: '%kernel.project_dir%/config/jwt/private.pem'
    public_key: '%kernel.project_dir%/config/jwt/public.pem'
    pass_phrase: 'jwtpass'
    token_ttl: 7200                            

I used the documentation here: https://github.com/lexik/LexikJWTAuthenticationBundle/blob/2.x/Resources/doc/index.rst#configuration.

Is there any way to change the token TTL from the yaml conf file ?

Edit:

here an example of generated token with brand new public/private keys generated using the documented method (https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.md#generate-the-ssh-keys-) :

eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE1NTA5MzAzNTIsImV4cCI6MTU1MDkzMzk1MiwidXNlcm5hbWUiOiJwYXJpc191c2VyQGNvbnRhY3QuY29tIn0.bUMkgNnzntDxga7Zz5nb2zAN2RUw5-jmVLPt9SECUxkXAjPBkB4W5vIFpkPKkPDdHL6qngGAq6rdgRxXur63YdnyDkkmE4dHbq9CVT38VvMszBR15TDavGkQxTdlBGDAqkft9pe72U_ipJYbbULYdTH6qvcXILTUOpZXfK2XRMsKFWilRZNQkeg7S-rISBb6VCSf-yEZjikwiNKfcexlrbs4PmfeK7oMYg1aN0JmTtmxQpikaRdbh8pd1wYm-_0mikr_Z9MSS24GYa2jys5q0TKpZMzibYie125faC6CU_63odlAjaIW66ZAeJsdQwiRZtNQzMEmzrfrxWtOhNqYjhM3KfVNR-x4tc5CaHzCWSUtXLOkvqMXCDjc9FIKQbXjA71UzvWwBnmwBlSxE63V6s8aamqG_N7mMUc2J--MxozrBynZmZIDFOT2dsHI6iiVBhgNhfhvhr4yTnW2GTQMPdOfgL-enagimrTUmGLA90h7e8h-osfkhv5qY0Omstqar9BCwzCabnh_j0enf3nmvgWAhc2MHbBlCcUnJYJQzMqdW_Pk9nmNePEetlbyrpVU7y_D_e1IAaafIMp0JJ4d5s6w5r31u0oYqYF3Vqh86Mp1cp99F6BcqBf03VvE1VWKeGATutTPKJfS93LspuDP7OcbJk2P3eG7Sxi2v4Y_gF0

Thanks in advance

Upvotes: 4

Views: 4387

Answers (2)

jean553
jean553

Reputation: 733

I have just realized that I defined my own token creation action, calling:

$this->get("lexik_jwt_authentication.encoder")->encode(array("username" => $username, "exp" => $expirationTime));

So there is no problem! ( the only problem is between the chair and the screen perhaps :) ). Sorry for that and @AythaNzt thanks for your reply anyway.

Upvotes: 4

AythaNzt
AythaNzt

Reputation: 1057

You are probably working in prod mode so you must clear cache.

Execute:

  • php bin/console cache:clear --no-warmup --env=prod
  • php bin/console cache:warmup --env=prod

Or change the APP_ENV value to dev.

Upvotes: 2

Related Questions