-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Update OidcWireMock to include the client_id in the ID token audience dynamically #43949
Update OidcWireMock to include the client_id in the ID token audience dynamically #43949
Conversation
🎊 PR Preview 744bc75 has been successfully built and deployed to https://quarkus-pr-main-43949-preview.surge.sh/version/main/guides/
|
This comment has been minimized.
This comment has been minimized.
Thanks @douglas444, I was thinking about it, and I wonder if we can just fix OidcWiremock instead to follow the OIDC spec requirement for ID token's audience be set to the client id. I can't find anywhere how to use a POST url form encoded parameter like This code must be updated, I've tried:
replacing Can you experiment please, and try to find the way to refer to the |
@sberyozkin I guess wiremock can't replace the placeholder because when Anyway, yes, I will experiment and let you know when I find a solution! Thank you for the reply! |
Thanks @douglas444, yeah, I forgot that the client id is coming by default in the Basic scheme, while not everyone is using a client post form authentication. Indeed, the only option is likely to be a custom transformer, have a look please |
That said, if requiring users setting the client post authentication option to have something like |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5612c6e
to
09762da
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@sberyozkin With the last commit, OidcWiremock will pick up the client_id and use it as the id token audience if the new Does this approach attend? Or maybe you meant "the client post authentication option" to be some flag signalized in the request instead of a new system property? The failed tests were an attempt to test without hardcoding the expected client_id. |
Hi @douglas444 Thanks a lot for figuring out how to get it done dynamically
We can safely drop this condition (and the added test), because this is what OIDC providers must do anyway, set the So please remove the added test and the new system property and it should all be good, you might need to tweak some oidc wiremock test properties which expect the custom audience, or you can set the |
Thanks @douglas444, that should be the best solution that you have come up with as none of the tests is broken |
@sberyozkin I was reading the oidc spec and it accepts other values to be included in the audience beyond the client_id. So there's no need to remove the |
This comment has been minimized.
This comment has been minimized.
829f5d4
to
3ba9c27
Compare
This comment has been minimized.
This comment has been minimized.
Status for workflow
|
This comment has been minimized.
This comment has been minimized.
5cae9e1
to
ca45c7d
Compare
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.
I will let @sberyozkin have a final look but I asked for a small change.
Thanks a lot for this contribution!
...ramework/oidc-server/src/main/java/io/quarkus/test/oidc/server/OidcWiremockTestResource.java
Outdated
Show resolved
Hide resolved
ca45c7d
to
64446f7
Compare
Thanks @gsmet @douglas444 |
Status for workflow
|
@douglas444 By the way, you can customize the authorization endpoint stub to have a better feel for your test code interacting with your provider |
Thanks @sberyozkin . I see. One thing that we can't customize though is the token generation. If the For instance I would like the id token to contain an email claim. How would you do this customization? Right now I think the only way is creating a stub that calls my own token generation methods. Maybe in a future PR we can add a protected instance method, or maybe we could add a property like |
@douglas444 Creating an out of the box OidcWiremock solution which works for all the variations and have everything parameterized is probably not possible, which is why users inject OidcWiremock directly into the test code (see CodeFlowAuthorizationTest which you also modified in this PR) and add specific stubs. You can override a token, user info, jwk, authorization and introspection endpoint addresses to point to the custom stub. Additionally you can try |
As mentioned in this discussion, Quarkus now enforces that the ID token aud is set to the client id and because the OidcWiremock code was created earlier, the ID token granted sets the aud to https://id.server.example.com. Because of that, tests that use OidcWireMockTestResource will not work unless the aud is customized through the
quarkus.oidc.token.audience
property.This PR updates the documentation to customize the audience used in the example for code-flow testing with OidcWireMock, making the example functional.