Symfony 4-Lexik/JwtAuthenticationBundle-无法更改令牌\u ttl默认值

Symfony 4-Lexik/JwtAuthenticationBundle-无法更改令牌\u ttl默认值,symfony,jwt,lexikjwtauthbundle,Symfony,Jwt,Lexikjwtauthbundle,我尝试将token\u ttllimit的值更改为lexik\u jwt\u authentication.yaml文件,但无论我设置了什么值,生成的令牌始终具有3600秒的ttl。我还设置了参数secret\u key和public\u key,并正确解释了这些参数 mylexik\u jwt\u authentication.yaml的内容是: lexik_jwt_authentication: secret_key: '%kernel.project_dir%/config/jwt

我尝试将
token\u ttl
limit的值更改为
lexik\u jwt\u authentication.yaml
文件,但无论我设置了什么值,生成的令牌始终具有3600秒的ttl。我还设置了参数
secret\u key
public\u key
,并正确解释了这些参数

my
lexik\u jwt\u authentication.yaml
的内容是:

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                            
我在这里使用了文档:

有没有办法从yaml conf文件中更改令牌TTL

编辑:

下面是使用文档化方法()生成的具有全新公钥/私钥的生成令牌的示例:


提前感谢

您可能正在prod模式下工作,因此必须清除缓存

执行:

  • php bin/控制台缓存:清除--无预热--env=prod
  • php bin/console缓存:warmup--env=prod

或者将APP_ENV值更改为dev.

我刚刚意识到我定义了自己的令牌创建操作,调用:

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

所以没问题!(唯一的问题可能是椅子和屏幕之间:))。对此表示抱歉,@AythaNzt感谢您的回复。

您能在7200粘贴一些带有令牌的令牌吗?我直接将其添加到原始消息中。这个令牌是用7200的令牌生成的,但是当我将它粘贴到jwt.io中时,exp datetime仍然比令牌创建时间晚3600秒。Mmm。。。您在.env中有prod或dev值吗?@jean553感谢您提供将令牌粘贴到jwt.io中以获取其过期时间的提示!我正在使用dev env。APP_ENV设置为“dev”(将环境变量放入我的development docker容器和.ENV文件中),我使用
php bin/console server:run
启动服务器。我执行了你给我uptop的两个命令,但是所有生成的令牌仍然有3600秒的TTL。
$this->get("lexik_jwt_authentication.encoder")->encode(array("username" => $username, "exp" => $expirationTime));