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

Fix OidcClient duplicating the client_id for the public client #26637

Merged

Conversation

sberyozkin
Copy link
Member

@sberyozkin sberyozkin commented Jul 10, 2022

Fixes #26619.

OidcClient has a cached MultiMap which keeps some properties which are reused across multiple token requests (ex, it has a client id and secret set if the client post authentication is required, and scopes) - but if the public client is used to request a token then the same client id is added to the same MultiMap.

So this PR does a minor update, copies the map to have a request specific map if the client is public (as it does in other cases) and it fixes the problem, the test has been added.

@@ -109,7 +109,7 @@ public Uni<Tokens> get() {
body.add(OidcConstants.CLIENT_ASSERTION, jwt);
}
} else if (!OidcCommonUtils.isClientSecretPostAuthRequired(oidcConfig.credentials)) {
body.add(OidcConstants.CLIENT_ID, oidcConfig.clientId.get());
body = copyMultiMap(body).add(OidcConstants.CLIENT_ID, oidcConfig.clientId.get());
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't changing to set enough here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@gastaldi Sorry, forgot to add a comment relating to set, since OidcClient will be reused by multiple threads, I decided to avoid set

Copy link
Contributor

Choose a reason for hiding this comment

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

Copying the MultiMap is fine, my question was more that if you call add again you will end up with more than one ClientID in the Map?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @gastaldi, sorry for asking to review on Sunday :-).
I see, so, in the original map client id is not present, this copy is created per every request and I guess, either set or add will do. I've added a test, as you can see in the original issue the duplication starts from a 2nd request (double add), so the test does 2 requests, I could confirm without the fix the 2nd request was failing.
if you'd like I can replace add with set, would not be a problem at all

Copy link
Contributor

Choose a reason for hiding this comment

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

No biggie, just curious really ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi George, just pushed a minor update, it is quiet today, so an extra CI run will not be a problem, set reads better for setting a single value property :-), thanks for the time

@sberyozkin sberyozkin force-pushed the oidc_client_duplicate_client_id branch from 7e704e6 to 8a00cfe Compare July 10, 2022 22:01
@gastaldi gastaldi added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jul 10, 2022
@sberyozkin sberyozkin merged commit f140504 into quarkusio:main Jul 11, 2022
@sberyozkin sberyozkin deleted the oidc_client_duplicate_client_id branch July 11, 2022 08:16
@quarkus-bot quarkus-bot bot added this to the 2.11 - main milestone Jul 11, 2022
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jul 11, 2022
@gsmet gsmet modified the milestones: 2.11.0.CR1, 2.10.3.Final Jul 18, 2022
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.

OIDC Client repeatedly adds client-id when no secret is specified
3 participants