-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How am I supposed to parse tokens created with: jwt.NewSerializer. #1133
Comments
You are ENCRYPTING and then SIGNING. |
Ah, ok. Thank you for the super fast reply. I did try that (see below) but I got the error decrypted, err := jwe.Decrypt([]byte(cookie.Value),
jwe.WithKeySet(e.keys.encrypt.public))
if err != nil {
return "", fmt.Errorf("failed to decrypt session cookie: %w", err)
} |
An, sorry, in your case you need to That is, you are doing |
I'm now doing the following:
But it will fail on the final parse because "decrypted" now just looks like this: Ofcourse, I now have the data I was looking for so it is fine. Just reporting here in case it's unexpected |
The last error is because you're trying to |
I will, thank you again for the quick responses (and the great library). I will close this, maybe others in the future have use for the information in this thread. |
no prob. Thanks for the kind words |
Thank you for this great library! I'm trying to store a refresh token in an encrypted JWT. Thinking I don't want to implement such critical security functionality from scratch I figured I used the high-level jwt.NewSerializer. It seems to allow for signing and encrypting a payload. But I don't understand how I'm supposed to parse it. I always seem to get
"unsupported format (#2)"
I great the token like this
The keys come from two key sets. One for encryption, one of signing (as I understand that we require different key for this). I then go ahead an try to parse it like this:
The
e.keys
, looks like this:This is an example token:
eyJhbGciOiJIUzI1NiIsImN0eSI6IkpXVCJ9.ZXlKaGJHY2lPaUpTVTBFdFQwRkZVQ0lzSW1WdVl5STZJa0V5TlRaSFEwMGlMQ0owZVhBaU9pSktWMVFpZlEubFVCR1NhcmFJOG9Sd29vRTBKblhnb3BFNndyS3gzZWxVUWdYczdSQ1RtUlpIR0NSVi1hdlpDdjQzUmltbUJ6RC1pa1JSWDJXNnVEcGVnbV9ZbVlxU3JKV2h2RW92SlRoSWpfQXJDaXN1OGR0M1NHRWJvR1RrWmU4TUE1VkN4RTFxNWthQTJ0bHhzeU5xWDN6MGcyd0daWXZSZ3JHSDJQZk5PVkxiQ2RxX0hmZmE5TER4U2pKNlRiZ0ZWZi1FSjJyMkdTS09HbHFFU2xPRGtoalp1b25RMXRkaWZvcDlDRXdsclp3S0ZPOUdRclBITkQxMkQwNmJvaVhnemhWWGUxTldsRklya3VLZ2xndXNoWGI1aDBHLWUzNnh4WWZEZUpOMTBJNXFtSTg1Y0tKV05vaHREWEtWa2JTaV94dnIwMWJCTGMzWHVSQmNabVJFSDdKQjdTYllBLklOUEY0YmlHbFlTTkpSdUkuWnNIQVVaeEtzb0tGTV84OUFVTDY2YU1GX21sUGFwYUNUSjEtLkdqNXNpRElRUWZvZ2YzR2pIY1JLOXc.w6o725mvW4bnZJ1XlzvnqAIQxIg13imuJwE6pLR1uyc
The testing keys I'm using look like this (well-known, just used for testing):
And
The text was updated successfully, but these errors were encountered: