-
Notifications
You must be signed in to change notification settings - Fork 166
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
Rethink order of JAX-RS filters in Polaris #819
Comments
I guess I have missed the commit where The |
@collado-mike polaris/service/common/src/main/java/org/apache/polaris/service/context/DefaultRealmIdResolver.java Line 29 in 390f1fa
Thanks for confirming, that was my conclusion as well. For the record, it was already being resolved prior to authentication, but with one annoying difference: the realm was being resolved as part of CDI resolution, see here: Lines 101 to 110 in df538b3
While this works well in the happy case (the realm can be resolved), it throws HTTP 500 in the unhappy case of wrong realm. Hence the changes in #848 : realm resolution is moved to a pre-auth filter: polaris/service/common/src/main/java/org/apache/polaris/service/context/RealmIdFilter.java Lines 48 to 56 in 9c45494
The filter resolves the realm, then sets it as a request property. Then CDI now simply reads the realm ID from the request property and produces the request-scoped bean that will be injected everywhere: Lines 101 to 105 in 9c45494
Does that make sense? |
Is your feature request related to a problem? Please describe.
Currently Polaris has a number of filters, some of them being "regular" JAX-RS filters, some others being Vert.x route filters:
QuarkusLoggingMDCFilter
RouteFilter.DEFAULT_PRIORITY + 100
(110)QuarkusTracingFilter
QuarkusLoggingMDCFilter.PRIORITY - 1
(109)PolarisPrincipalAuthenticatorFilter
Piorities.AUTHENTICATION
(1000)PolarisPrincipalRolesProviderFilter
Piorities.AUTHENTICATION + 1
(1001)RateLimiterFilter
Piorities.USER
(5000)The above has a number of issues:
First off, from my experience, Vert.x filters always execute first, regardless of priorities (also, Vert.x priorities are inverted compared to JAX-RS ones). This induces a wrong order of execution:
QuarkusLoggingMDCFilter
QuarkusTracingFilter
PolarisPrincipalAuthenticatorFilter
PolarisPrincipalRolesProviderFilter
RateLimiterFilter
Secondly, we ideally need a filter to verify realm IDs. For two reasons:
QuarkusLoggingMDCFilter
andQuarkusTracingFilter
both need the realm ID. So they should execute after the realm ID filter.Describe the solution you'd like
I think we need to reorder the filters as below:
RealmIdFilter
(to be created)QuarkusLoggingMDCFilter
QuarkusTracingFilter
PolarisPrincipalAuthenticatorFilter
PolarisPrincipalRolesProviderFilter
RateLimiterFilter
Or maybe as below if we want the authenticator to kick in first:
PolarisPrincipalAuthenticatorFilter
RealmIdFilter
(to be created)PolarisPrincipalRolesProviderFilter
QuarkusLoggingMDCFilter
QuarkusTracingFilter
RateLimiterFilter
We may need to convert the Vert.x filters into JAX-RS ones, or the other way around.
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: