JWTDecodeFailureException - 无法通过给定的配置验证给定的 JWT
JWTDecodeFailureException - Unable to verify the given JWT through the given configuration
我大约 3 天都处于糟糕的状态,我正在尝试制作一个简单的身份验证和注册应用程序,但是在使用我生成的令牌时我总是遇到这个 500 错误:
Unable to verify the given JWT through the given configuration. If the "lexik_jwt_authentication.encoder" encryption options have been changed since your last authentication, please renew the token. If the problem persists, verify that the configured keys/passphrase are valid.
我想知道实际上有什么不好,这是我的配置:
在 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
security.yml
```
防火墙:
主要的:
模式:^/
匿名:真实
无状态:真
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 SF 3.3@dev 上,似乎在版本之间的某个地方发生了崩溃。尽管如此,即使在更新 keys/regenerating 令牌之后,目前也没有什么好处,而且我总是遇到这个错误。
我目前正在通过 Postman 处理我的请求,令牌已正确生成并且问题不是来自 header 中的授权参数,我已经尝试了很多东西来查看不管是不是我的错,在这种情况下似乎不是,
非常感谢任何关于此的帮助/提示:)
您应该使用以下命令重新生成您的 public 和私钥:
openssl genrsa -out config/jwt/private.pem -aes256 4096
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem
并确保密码为“pass”以使配置生效。
我大约 3 天都处于糟糕的状态,我正在尝试制作一个简单的身份验证和注册应用程序,但是在使用我生成的令牌时我总是遇到这个 500 错误:
Unable to verify the given JWT through the given configuration. If the "lexik_jwt_authentication.encoder" encryption options have been changed since your last authentication, please renew the token. If the problem persists, verify that the configured keys/passphrase are valid.
我想知道实际上有什么不好,这是我的配置:
在 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
security.yml ``` 防火墙: 主要的: 模式:^/ 匿名:真实 无状态:真
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 SF 3.3@dev 上,似乎在版本之间的某个地方发生了崩溃。尽管如此,即使在更新 keys/regenerating 令牌之后,目前也没有什么好处,而且我总是遇到这个错误。
我目前正在通过 Postman 处理我的请求,令牌已正确生成并且问题不是来自 header 中的授权参数,我已经尝试了很多东西来查看不管是不是我的错,在这种情况下似乎不是,
非常感谢任何关于此的帮助/提示:)
您应该使用以下命令重新生成您的 public 和私钥:
openssl genrsa -out config/jwt/private.pem -aes256 4096
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem
并确保密码为“pass”以使配置生效。