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

Allow restricting OidcRequestFilters to specific OIDC endpoints #37257

Merged
merged 1 commit into from Dec 1, 2023

Conversation

sberyozkin
Copy link
Member

Fixes #37256

@quarkus-bot

This comment has been minimized.

Copy link
Contributor

@pedroigor pedroigor left a comment

Choose a reason for hiding this comment

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

A few comments ...

@sberyozkin
Copy link
Member Author

@pedroigor I'll need to update the docs

@sberyozkin
Copy link
Member Author

@pedroigor Let me drop scope property for now as it addresses a rare case which has not yet occurred, and we can review it when users ask for it

@sberyozkin
Copy link
Member Author

Let me also investigate the option of injecting OidcConfigurationMetadata

@pedroigor
Copy link
Contributor

pedroigor commented Nov 24, 2023

@sberyozkin The point about injecting metadata is that we still allow users to perform decision checks based on the client request URL and the URL from the metadata. For instance, to filter only requests to the JWKS endpoint, we would have something like that in a filter implementation:

if (metadata.getJwksUrl().equals(request.url()) { // do filter request }

The main reason for this is to avoid additional complexity for Oidc Client and reduce maintenance burden when supporting additional endpoints.

@quarkus-bot quarkus-bot bot added area/docstyle issues related for manual docstyle review area/documentation labels Nov 28, 2023
@quarkus-bot quarkus-bot bot added this to To do in Quarkus Documentation Nov 28, 2023
@sberyozkin sberyozkin changed the title Allow restricting OidcRequestFilters to specific OIDC endpoints and scopes Allow restricting OidcRequestFilters to specific OIDC endpoints Nov 28, 2023
@sberyozkin
Copy link
Member Author

Hi @pedroigor, I've done some updates to this PR, and @michalvavrik also helped out analyzing the metadata injection options. So here is is the summary:

  • I've got rid of the Scope enum for now as agreed, lets see if users will ever need it
  • I've added a support for the filters to access OidcConfigurationMetadata - Michal and myself looked into it and injecting it via the request scope is messy and tricky, another option was to pass via the Vertx duplicated context, but eventually the simplest solution was found where we can simply pass it as one of the properties in OidcRequestContextProperties - which is available as a filter method parameter. Unfortunately, Vert.x HttpRequest.uri() returns relative path only while the discovered metadata contains absolute URI, so users would have to write the code like this one: https://github.com/quarkusio/quarkus/pull/37257/files#diff-8f3225844cc7a339b14050ce3a5d9e172a0c0d7628ac0f01236c357020c7d9c4R23 but I have to admit I'm not too excited about it, as one need to check the JWK/etc endpoints for null (will be null for OAuth2 servers, or when the discovery is disabled), but it is definitely a viable option in simple setups
  • Retained an Endpoint enum option: https://github.com/quarkusio/quarkus/pull/37257/files#diff-3425fd162ebeddd5d267c2b1032832f28419cb5605b5bf74ccd0bfba34773820, for me it looks like the easiest option - it is not difficult to maintain - I can't imagine this enum changing, if it at all, during the next 6 or 12 months :-). Annotation based approach would definitely be trickier to implement - this will involve the addition of 7 or so new annotations to the API among other things which I'd probably like to avoid.

IMHO it is a reasonable compromise - if users want to filter all the endpoints or say only 2 of them, then OidcConfigurationMetadata checks can be handy, for single endpoints, Endpoint enum works very well IMHO.

How does it sound ?

@quarkus-bot

This comment has been minimized.

@sberyozkin
Copy link
Member Author

sberyozkin commented Nov 28, 2023

Dropped a noteworthy feature label as it is more like a necessary improvement

@sberyozkin
Copy link
Member Author

/cc @pedroigor @calvernaz

Hey Pedro, I hope you'll be glad to know I've decided to follow your suggestion and I've dropped OidcRequestFilter#endpoint() which this PR started from, and users can restrict with annotations, for example: https://github.com/quarkusio/quarkus/pull/37257/files#diff-3425fd162ebeddd5d267c2b1032832f28419cb5605b5bf74ccd0bfba34773820R15

So, now users can either restrict to specific endpoints using annotations or use OidcConfigurationMetadata to filter requests to all the endpoints.

@sberyozkin
Copy link
Member Author

Unfortunately I forgot again to update the docs, done now

@quarkus-bot
Copy link

quarkus-bot bot commented Nov 30, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Quarkus Documentation automation moved this from To do to Reviewer approved Dec 1, 2023
@sberyozkin sberyozkin merged commit b153b63 into quarkusio:main Dec 1, 2023
26 checks passed
Quarkus Documentation automation moved this from Reviewer approved to Done Dec 1, 2023
@sberyozkin sberyozkin deleted the oidc_request_filter_type branch December 1, 2023 14:34
@quarkus-bot quarkus-bot bot added the kind/enhancement New feature or request label Dec 1, 2023
@quarkus-bot quarkus-bot bot added this to the 3.7 - main milestone Dec 1, 2023
Copy link

github-actions bot commented Dec 1, 2023

🙈 The PR is closed and the preview is expired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docstyle issues related for manual docstyle review area/documentation area/oidc kind/enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

Allow restricting OidcRequestFilter to specific OIDC endpoints and scopes
2 participants