8000 DPoP verification in UserInfo endpoint by tnorimat · Pull Request #22240 · keycloak/keycloak · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

DPoP verification in UserInfo endpoint #22240

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

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

tnorimat
Copy link
Contributor
@tnorimat tnorimat commented Aug 4, 2023

closes #22215

@tnorimat tnorimat requested review from a team as code owners August 4, 2023 05:13
@tnorimat tnorimat requested a review from a team August 4, 2023 05:13
@tnorimat tnorimat requested a review from a team as a code owner August 4, 2023 05:13
@tnorimat
Copy link
Contributor Author
tnorimat commented Aug 4, 2023

@mposolda The PR resolve the one issue of the epic #21916 . Could you check it?

Copy link
Contributor
@mposolda mposolda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tnorimat I've added one comment inline. I am curious for your opinion on this.

@@ -251,6 +254,18 @@ private Response issueUserInfo() {
}
}

if (Profile.isFeatureEnabled(Profile.Feature.DPOP)) {
if (OIDCAdvancedConfigWrapper.fromClientModel(clientModel).isUseDPoP() || request.getHttpHeaders().getHeaderString(DPoPUtil.DPOP_HTTP_HEADER) != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that if client doesn't require DPoP, but still DPoP was used during authentication, the validation won't be done in case that DPoP header is not present in UserInfo endpoint.

To me, it would makes sense to require validate DPoP always if it was used during authentication? In case that accessToken contains thumbprint, it means that DPoP was used during authentication and in that case, it might be always verified? So I can think about something like this:

            if (OIDCAdvancedConfigWrapper.fromClientModel(clientModel).isUseDPoP() || accessTokenHasDPoPThumbprint()) {

WDYT? Can that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. The current PR bypasses the DPoP verification when a client sends DPoP bound access token without DPoP proof header. I will fix the PR as you suggested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think that if we address #21919, the token type should be set as DPoP. So in that case, the check can be even simpler as:

if (OIDCAdvancedConfigWrapper.fromClientModel(clientModel).isUseDPoP() || DPoPUtil.DPOP_TOKEN_TYPE.equals(token.getType())) {

or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I used DPoPUtil.DPOP_TOKEN_TYPE.equals(token.getType()).

@tnorimat tnorimat force-pushed the ISSUE-22215-dpop-userinfo branch 2 times, most recently from 83f3238 to 142da2e Compare August 4, 2023 07:31
@mposolda
Copy link
Contributor
mposolda commented Aug 4, 2023

@tnorimat I think DPoPTest is failing in this PR due the same I've already mentioned here #22244 (review) . I think that once we set token type in the token itself, this test will start to work. So perhaps this PR can be done as a follow-up to #22244 in case that you change the token type in that PR #22244?

I guess that it would be possibly needed also to update some checks - like TokenVerifier.withDefaultChecks() to make sure that UserInfo allows both Bearer or DPoP as token types, which would be fine IMO.

@tnorimat
Copy link
Contributor Author
tnorimat commented Aug 7, 2023

@mposolda I resolved the errors of the CI tests. Could you check the revised PR?

@mposolda mposolda merged commit 258711e into keycloak:main Aug 7, 2023
@mposolda
Copy link
Contributor
mposolda commented Aug 7, 2023

@tnorimat Nice, Thanks

@tnorimat tnorimat deleted the ISSUE-22215-dpop-userinfo branch November 12, 2023 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DPoP verification in UserInfo endpoint
2 participants
0