You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while on the consume side, jwt_secrets.rsa_public_key MAY get base64 decoded when plugin_conf.secret_is_base64 is switched on, with no regard to whether the crypto used is symmetric or asymmetric
localjwt_secret_value=algorithm~=nilandalgorithm:sub(1, 2) =="HS" andjwt_secret.secretorjwt_secret.rsa_public_keyifconf.secret_is_base64thenjwt_secret_value=jwt:base64_decode(jwt_secret_value)
end
In scenarios with algorithm='RS256' and conf.secret_is_base64=true, jwt:base64_decode(jwt_secret_value) will always fail, which lead to issues like #2891 .
We can work around this problem by switching off secret_is_base64, just like @smileMrLee did in #2891 . Or we can make a fix to jwt/handler.lua by check the necessity of base64 decoding with regard to both algorithm and conf.secret_is_base64:
localis_symmetric_algorithm=algorithm~=nilandalgorithm:sub(1, 2) =="HS"localjwt_secret_value=is_symmetric_algorithmandjwt_secret.secretorjwt_secret.rsa_public_keyifis_symmetric_algorithmandconf.secret_is_base64thenjwt_secret_value=jwt:base64_decode(jwt_secret_value)
end
The text was updated successfully, but these errors were encountered:
jizhilong
changed the title
validation rule for jwt_secrets.rsa_public_key is inconsistent between the write side and consuming side
validation rule for jwt_secrets.rsa_public_key is inconsistent between the write side and consume side
Sep 25, 2024
Hello @jizhilong, thank you for opening this issue. It appears you have a solution coded for this problem, would you consider opening a pull request? Thank you!
Is there an existing issue for this?
Kong version (
$ kong version
)2.2.2+
Current Behavior
No response
Expected Behavior
No response
Steps To Reproduce
No response
Anything else?
jwt_secrets.rsa_public_key
MUST be content of a plain text pem file when asymmetric crypto is used.jwt_secrets.rsa_public_key
MAY get base64 decoded whenplugin_conf.secret_is_base64
is switched on, with no regard to whether the crypto used is symmetric or asymmetricIn scenarios with
algorithm='RS256'
andconf.secret_is_base64=true
,jwt:base64_decode(jwt_secret_value)
will always fail, which lead to issues like #2891 .We can work around this problem by switching off
secret_is_base64
, just like @smileMrLee did in #2891 . Or we can make a fix tojwt/handler.lua
by check the necessity of base64 decoding with regard to both algorithm andconf.secret_is_base64
:The text was updated successfully, but these errors were encountered: