Skip to content
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

"Unexpected token algorithm" error when validating CloudFlare's JWT #13

Open
petersondmg opened this issue Oct 10, 2022 · 2 comments
Open

Comments

@petersondmg
Copy link

petersondmg commented Oct 10, 2022

Hello,
I'm trying to validate Cloudflare Zero Trust JWT, but I'm getting the error "jwt: unexpected token algorithm". Looking at the code, I think the problem is related to this line the compares the header, since the JWT from CF doesn't have the "typ" field.

The line:

jwt/token.go

Line 169 in d03e03a

return Base64Encode([]byte(`{"alg":"` + alg + `","typ":"JWT"}`))

Cloudflare doc: https://developers.cloudflare.com/cloudflare-one/identity/authorization-cookie/validating-json/

Thank you.

@petersondmg petersondmg changed the title Unexpected token algorithm when validating CloudFlare's JWT "Unexpected token algorithm" error when validating CloudFlare's JWT Oct 10, 2022
@ThinhNX
Copy link

ThinhNX commented Mar 29, 2023

Have you fixed this bug yet?
Im facing the same issue right now with an offline server and I dont have any solutions for it.

@borissov06
Copy link

This error also happens when the header contains a "kid" claim: the comparison only expects "alg" and "typ".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants