-
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
WebSocket + Role-based authentication stopped working with Quarkus 3.9.x: Security Identity is not available #40307
Comments
/cc @sberyozkin (security) |
@lyrst Thanks for the reproducer Thanks |
I don't recall us providing any doc-ed recommendations along those lines, so may be we can recommend to switch to WebSockets Next to achieve the expected RBAC ? |
I have no idea.
Yes, I've created #40312 to track our security-related efforts for WebSockets Next. |
I tried to use the new WebSocketNext extension as I thought that the |
Yes, the integration with the security extension is currently WIP. |
NPE is thrown in Quarkus REST handler, I'll have a look. |
I'm afraid this will take a CDI expert, at the very least to give me a hint. I'll write you an email. |
Hm, so if I understand it correctly the failing test ( |
That's correct. The HTTP request comes into the WebSocket handler, but leaves it as it does not detect the WS header. |
When Reactive Routes are used together with Quarkus REST and some
Interesting is also why the state has changed, I added printing of a stack trace, however it's too long to put here. See the attachment. What fixes (or works around?) the issue is for example this: bf7880ab3 I found other ways to work around the issue, but it really requires a feedback from a CDI experts to determine the one that should be used. Use reproducer from the description. Thank you |
My simplistic understanding is that the context state changes when subscribed |
It seems like
Yes, my debugging attempts landed at pretty much the same thing to resolve it - manovotn@7923d22 That being said, I am still unsure about:
|
Very nice @manovotn , thank you for looking at it! I might not be a good adept to answer the questions raised, maybe someone else will, but I'll try.
lgtm, but tests will be needed. I can prepare them.
I was asking myself a same thing, but considering that Reactive Routes are "finished product" (the way I see it; it's removed from RHBQ at least and recently dropped from SR JWT) I don't want to propose important changes there.
My thinking was that we should not accept that users activate CDI request context. If user code or extensions activate CDI request context prior to Quarkus REST processing, they should destroy it as well. This is very early in processing and user code often needs Quarkus REST to prepare the request context for example with current identity and RoutingContext. We know how to handle and detect case when Reactive Routes activate it, but we can't really keep checking if someone destroyed active context during the processing inside Quarkus REST, can we? Wouldn't it require loop constantly checking as it can be async process? So my thinking was that we allow it for Reactive Routes, but consider it "illegal state" when it comes in other cases. What should be done I'm not sure. Can we destroy the activate request context ourself and activate a new one? It is enough for cases where concrete state is kept, but not enough when someone simply calls
+1 |
That would be awesome, thank you.
There are CDI APIs allowing you to programmatically activate req. context and even more of them in Arc itself. However, I don't think you'd be able to get that far without first activating it from within some other Quarkus part.
Yea, if you go on tempering with context activation and destruction forcefully, you are IMO on your own.
I'd say it is generally easier to respect if the context is already active when your framework/integration needs it and just reuse that one. Whoever creates the context is also responsible for its destruction. |
Let me try and summarize so as to check if I have understood the issue correctly: There is some piece of code that runs in a Vertx route that runs before Quarkus REST and that route activates the CDI context which then Quarkus REST completely ignores and starts a new one? |
(in short :-)) @manovotn I agree with your conclusions / answers. Thank you.
So far I believe we can in case of Reactive Routes.
yes
I think it comes from refactoring of the |
It's definitely possible to use the existing request scoped state if it exists, but is that really something we want to do in all cases? |
Can you think of a case where that would be an issue? |
Not off hand |
What I think can become problematic is how we handle the end of the request processing in Quarkus REST. Currently as we always start the context, we always terminate it as well. If however now we move to not starting the context, what is the expectation going to be about closing it? |
#40388 is a draft that reuses the request context which you folks can use to test. |
That it is handled by whoever started it. Which is the case that I observed in this reproducer as well (see last bit of #40307 (comment))
+1, this is very similar to what I proposed earlier (manovotn@7923d22) and to what Michal has (bf7880ab3). |
Theoretically yes, but is that actually the case in practice. |
A repeated invocation of context destruction is a no-op (as is the case in the reproducer). |
Right, that's my point. I'll update my draft PR soon |
I didn't really find a way to do that, because I don't see how I can attach anything to the |
@geoand you cannot attach anything to it. |
We can do that I guess |
They were failing in a presence of a router filter and resteasy-reactive dependency quarkusio/quarkus#40307 https://issues.redhat.com/browse/QQE-692
They were failing in a presence of a router filter and resteasy-reactive dependency quarkusio/quarkus#40307 https://issues.redhat.com/browse/QQE-692
They were failing in a presence of a router filter and resteasy-reactive dependency quarkusio/quarkus#40307 https://issues.redhat.com/browse/QQE-692
They were failing in a presence of a router filter and resteasy-reactive dependency quarkusio/quarkus#40307 https://issues.redhat.com/browse/QQE-692
* Coverage for JSON tokens https://issues.redhat.com/browse/QUARKUS-4179 * Cover client handling server failures https://issues.redhat.com/browse/QQE-692 quarkusio/quarkus#37323 * Cover case of failing security tests They were failing in a presence of a router filter and resteasy-reactive dependency quarkusio/quarkus#40307 https://issues.redhat.com/browse/QQE-692 * Add coverage for max parameters of multipart tweak mulripart tests fix for loop initial from 0 * Update to 3.8.5 --------- Co-authored-by: jcarranzan <[email protected]>
Describe the bug
I hava a WebSocket-endpoint that is secured with the "RolesAllowed"-annotation.
In order to secure the websocket endpint I followed the approach that is described here #29919
The issue that the Test
testFoo1Endpoint
does not even run with aNullPointerException
.As soon as I switch to Quarkus 3.8.4 the tests fails with an assertion-related error.
Expected behavior
The
testFoo1Endpoint
-tests is able to run without theNullPointerException
.Actual behavior
The
testFoo1Endpoint
-tests is fails with aNullPointerException
.How to Reproduce?
Run the following example code.
quarkus-sec-issue.zip
Output of
uname -a
orver
Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:25 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6030 arm64
Output of
java -version
No response
Quarkus version or git rev
3.9.4
Build tool (ie. output of
mvnw --version
orgradlew --version
)mvn
Additional information
No response
The text was updated successfully, but these errors were encountered: