-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix validation of external tokens without typ claim #33344
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
Conversation
Closes keycloak#33332 Signed-off-by: Venelin Cvetkov <[email protected]>
e6e0a6c to
4b4cd97
Compare
|
@cvetkovv Thanks for the PR. The change makes sense to me. @pedroigor What do you think? @cvetkovv Is it possible to add automated test for this change? For example you can take a look at |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.broker.KcOidcBrokerTest#testPostBrokerLoginFlowWithOTP_bruteForceEnabledKeycloak CI - Java Distribution IT (windows-latest - temurin - 17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unreported flaky test detected, please review
pedroigor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cvetkovv Can we do the other way around? Override the method on the Microsoft provider implementation instead?
The reason is that even though typ is optional for general JWTs by looking at the JWT specs, it is not for others types of tokens such as ID tokens.
Better have this constraint removed only for Microsft and enforce the claim for other providers. Or do we have other providers with the same problem?
|
I would like to request for this fix to be included in the Generic OIDC provider since it affects my use cases. I have integrated keycloak with proprietary OIDC implementations that do not include the optional typ field in the token body. |
|
Unfortunately we will not be doing any more releases in the 25.x series, your best bet will be to upgrade to 26.x. |
We are seeing a similar issue with GitHub ID tokens. The ref: #30021 (comment) |
|
I also stumbled upon this issue this week while trying to exchange an EntraID IDToken to a Keycloak access token, and I also failed on the missing JsonWebToken type. How about setting the I tried to refactor the JWT parsing logic in OIDCProvider which also sets the With that in place I could successfuly exchange a EntraID ID token into a Keycloak Access token with the following request: |
FWIW, I have two comments on this:
If I think ignoring the |
|
I added another PR with new opt-in param to skip the |
Makes sense. Maybe i wrong in my assumption/reading of the code that getType returned the type header, you're saying this is parsing just the claims? For reference, here is the decoded (and redacted) GitHub token |
|
At least in which is parsed from the value of
|
|
This fix is not ideal. There are IDP's out there that follow https://datatracker.ietf.org/doc/html/rfc7519#section-5.1, by putting "JWT" in the "typ" claim. Making this validation configurable would be more desirable (#35075) |
|
Is there any ETA for this fix ? Thank you |
|
Closing due to #35075 now being merged. |
Closes #33332