JWTDecodeFailureException-无法通过给定的配置验证给定的JWT



我在大约3天的糟糕情况下,我正在尝试进行一个简单的auth&注册应用程序,但我在使用我生成的令牌时总是会收到这个500错误:

无法通过给定的配置验证给定的JWT。如果自上次身份验证以来"lexik_jwt_authentication.encoder"加密选项已更改,请续订令牌。如果问题仍然存在,请验证配置的密钥/密码短语是否有效。

我想知道什么是不好的,实际上,这是我的配置:在parameters.yml中 jwt_public_key_path: '%kernel.root_dir%/../var/jwt/public.pem' jwt_private_key_path: '%kernel.root_dir%/../var/jwt/private.pem' jwt_key_pass_phrase: pass jwt_token_ttl: 3600

config.yml lexik_jwt_authentication: private_key_path: '%jwt_private_key_path%' public_key_path: '%jwt_public_key_path%' pass_phrase: 'pass' token_ttl: '36000' token_extractors: authorization_header: # look for a token as Authorization Header enabled: true prefix: Bearer name: Authorization cookie: # check token in a cookie enabled: false name: BEARER query_parameter: # check token in query string parameter enabled: false name: bearer

证券yml```防火墙:main:图案:^/匿名:true无状态:真正的

logout:       true
anonymous:    true
guard:
authenticators:
- 'token_authenticator'
login:
pattern:  ^/api/login
stateless: true
anonymous: true
form_login:
check_path:               /api/login_check
success_handler:          lexik_jwt_authentication.handler.authentication_success
failure_handler:          lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
username_parameter: username
password_parameter: password
api:
pattern:   ^/api
stateless: true
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

```

我使用的是v2.4/w SF3.3@dev,似乎在两个版本之间的某个地方发生了故障。尽管如此,即使在续订密钥/重新生成令牌之后,目前也没有什么好的,我总是犯这个错误。

我目前正在通过Postman处理我的请求,令牌是正确生成的,问题不是来自标题中的Authorization参数,我在上面试了很多东西,看看这是否是我的错,在这种情况下似乎不是,

任何关于这方面的帮助/提示都将不胜感激:)

您应该使用以下命令重新生成公钥和私钥:

openssl genrsa -out config/jwt/private.pem -aes256 4096
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem

并确保密码短语为">pass",以使配置正常工作。

最新更新