-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Selecting OIDC tenant via annotation is not working with RESTEasy Reactive #34692
Comments
/cc @pedroigor (oidc), @sberyozkin (oidc) |
@Eng-Fouad Hey, See the note there about the proactive authentication having to be disabled - this is the only way to capture it |
It is already disabled:
|
@Eng-Fouad Can you check this test: c6e16a2#diff-413ec7589b4f774d8b6b1dd5e222db550f79bb4084e36af4c986f6f7aa5ae273 May be you need to move |
I believe this test evaluates tenant after authentication succeeded. The authentication uses default tenant config, as
Same result. |
@Eng-Fouad My guess it needs to have a higher priority, the tenant resolver interceptor, than that of the security CDI interepceptors, Also CC @michalvavrik |
I tried |
@Eng-Fouad I've debugged and it works as expected. I've looked at your code above - where do you set the authentication/rbac requirement ? Please also keep in mind that if you have a registered |
@Eng-Fouad I've opened a PR which will fix this issue - but please reopen it if it will be merged before you get a chance to double check, and provide a reproducer, thanks |
OK, I figured out what the issue was. I had
EDIT: After removing |
@sberyozkin I think I understand now why it fails for me but it works in integration-tests. In the following test: quarkus/integration-tests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/TenantEchoResource.java Lines 22 to 30 in 79ccc09
Access to identity is preformed after JAX-RS resource is called. In other words:
While using
BTW, I couldn't re-open this issue :) |
Hmm, yes, I think it makes sense @Eng-Fouad , it goes down to |
@Eng-Fouad I can't reproduce it though, please provide reproduce but what you describe seems to be already tested. |
aaahh! ok, oidc-wiremock is using Resteasy classic, let me re-check again. |
Okay, simply replacing RC with RR makes a trick, I'll have a look. |
@Eng-Fouad can you confirm you are using RESTEasy Reactive? |
That's correct. I am using RESTEasy Reactive:
|
Thanks @Eng-Fouad @michalvavrik. The test uses |
Yeah, CDI interceptors can't be used for this purpose as auth is done before CDI interceptors and it is correct design - so with RR https://quarkus.io/guides/security-openid-connect-multitenancy#resolving-tenant-identifiers-with-annotations wont' work. @sberyozkin any special reason why it has to be CDI interceptors? There is a way to make this work as long as you won't insist on interceptors in RR, we can simply provide interface and will users implement and then we can check in EagerSecurityHandler what annotations there are on method. Pros
Cons
|
Well, as you see is that it does work for RestEasy classic - so it is related to the way RestEasy Reactive handles it ? |
Yes, it is @sberyozkin; it is for long debate that we sort of lead when discussing using |
fyi @sberyozkin this is similar case to #32049 which shame on me, I'm yet to document (I'll do it this weekend). |
We already have
When it is critical not to read some massive input stream before the security check then sure, users can avoid this feature and we can warn them against using it in such cases, but IMHO, it should work for Reactive same way as it does for Classic |
Yes, and as I said, this can be done. Let me sort this issue out. Only thing I need from you is acceptance that CDI interceptors won't be required (but still can work for RC).
There is a lot of strong opinions in that. I'd like to avoid this discussion as long as we can make it work without interceptors (btw it is purely intentional #19598). But sure, I'm happy to hear your POV. |
Maybe I wasn't clear, we can make it possible for RR methods to select tenants with annotation. |
Absolutely, yeah, I'm not really that fond of CDI interceptors as such, I'm just not seeing as far, how this can work without them, but have a look please when you'll get a chance, cheers |
Thanks! |
Thanks Michal |
What I'm not sure about is how you'd do it at the Resteasy Reactive level given that it is an OIDC specific feature, setting its tenant identifiers. The reason it works (at least for classic) with CDI interceptors is that CDI |
Or, may be we just say, implement RR ServerHandler or something like that... OK, I'll keep quiet now :-) |
I don't have answer for that - I'm wondering about that as well. Only thing that is clear to me is that at this very point Line 72 in 65ca2db
I will think, bring suggestions if you have them :-) |
My understanding ServerHandler runs very close to the actual method invocations in RR, but I'm not sure how we'd package/implement it at the RR level as we can't ship it with quarkus-oidc |
There is actually little hack that could help us, if we refactor
to something like
I didn't think this through @sberyozkin , but as POC before I know more, it looks good to me and it shall work for both RC and RR. It is well possible I am missing something, I'll come back to it when I have a time, but feedback is welcomed. |
Maybe we could be more explicit though, as |
Last comment so that I'm not spamming: adding it to |
Hey @michalvavrik Sorry, missed it, for the annotation based tenant id resolution it would not be a problem at all, it being called multiple times. |
I think I found bit more generic solution in mind, because ability to connect method to request when |
Describe the bug
According to OIDC docs, one can select OIDC tenant via annotation as follows:
Expected behavior
Authentication of
/hr
endpoint should be based onquarkus.oidc.hr.*
configs.Actual behavior
Authentication of
/hr
endpoint uses the default tenant configsquarkus.oidc.*
as authentication is triggered beforeHrTenantInterceptor
, hence the authentication fails.Quarkus version or git rev
3.2.0.Final
The text was updated successfully, but these errors were encountered: