Closed lubw7 closed 7 months ago
Not sure whether if https://github.com/Kong/kong/pull/11569 affectted it, we need to check
We have created a ticket to track this issue (KAG-3952), thanks for your report.
jwt token should be encoded with Base64URL algorithm, which means that we should replace '+' to '-' and '/' to '-'.
The variable test_key
includes invalid char /
, so kong think it is a wrong base64url string.
You can change the code like this:
local input = "..."
input = input:gsub("+", "-"):gsub("/", "_")
print(jwt_decoder:base64_decode(input))
Thanks, the problem has already been solved.
You can change the code like this:
local input = "..." input = input:gsub("+", "-"):gsub("/", "_") print(jwt_decoder:base64_decode(input))
@chronolaw Will this change be added to the source code?
You can change the code like this:
local input = "..." input = input:gsub("+", "-"):gsub("/", "_") print(jwt_decoder:base64_decode(input))
Is there an existing issue for this?
Kong version (
$ kong version
)kong 3.6
Current Behavior
In Kong 3.6.0 When I use kong.plugins.jwt.jwt_parser:base64_decode, it will meet exception : nil,invalid input.
2024/03/01 16:14:10 [debug] 1277#0: *1286 [lua] sso.lua:119: jwt_decoder:base64_decode(key) = nilinvalid input
Expected Behavior
In Kong 3.4.2 When I use kong.plugins.jwt.jwt_parser:base64_decode, it will decode successfully.
Steps To Reproduce
2024/03/01 16:14:10 [debug] 1277#0: *1286 [lua] sso.lua:119: jwt_decoder:base64_decode(key) = nilinvalid input
Anything else?
https://github.com/Kong/kong/pull/11569 refactor the code about jwt_parser:base64_decode, so is it expected that such an error will occur?