Closed thomasleplus closed 3 years ago
Hi @thomasleplus, you can't just load without setting the algorithm. Can you potentially edit your post to have multiple lines to be sure I'm reading the code correctly?
This package supports many different signatures out of the box like HMAC and different versions of RSA so you have to set them before you can load and verify.
Hi @cdbattags,
First of all thanks for trying to help me. I have reformatted my code example for better readability.
I am not sure I understand your point about setting the algoritm. I thought that JWT header was declaring the algorithm being used. In my example, if I decode the JWT, the header says that the signature algorithm used is RS256 (RSA + SHA-256):
{
"alg": "RS256",
"typ": "JWT",
"kid": "DIyuraH7uTaZWCR8Id_XwpwaZfahwb9L4ZFH5Suebl4"
}
Either way I am not trying to validate the token's crypto here. I just want to base64 decode / pretty print the token (for debug log purposes). So maybe I am using the wrong method here, i.e load_jwt()?
Regards,
Tom
@thomasleplus did you get a solution to this? I hit the same challenge today.
Hi @marrobi, no I have not resolved my issue yet.
For now I am using resty.openidc
and jwt_verify
. This seems to wrap load_jwt
, and returns the json object I wanted.
Thanks @marrobi, it worked. jwt_verify only gives me the decoded JWT payload, not the header, but I can live with that.
Hello,
Sorry I am a complete beginner at Lua so I am probably missing something obvious but I am trying to decode a JWT like this:
But what I am getting is:
When I test the same JWT on https://jwt.io/#debugger-io?token=... it decodes successfully (but they could be using a more lenient parser) and the signature seems valid.
Any idea what the problem could be? I am using v0.2.2 in case it matters.
Cheers,
Tom