-
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
WebSocket NEXT: automatically close connection when OIDC extension provides SecurityIdentity and token expires #40857
WebSocket NEXT: automatically close connection when OIDC extension provides SecurityIdentity and token expires #40857
Conversation
michalvavrik
commented
May 27, 2024
•
edited by geoand
Loading
edited by geoand
- Closes: WebSockets Next: close the connection if the security identity has expired #40536
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🙈 The PR is closed and the preview is expired. |
Thanks @michalvavrik. Can users have a chance to react to this closure somehow, have the error handler called etc ? |
c52ca24
to
4de8315
Compare
Connection is getting closed, you shouldn't be able to stop it. What else can be done? If we only fired on error, there are 4 strategies (close, log, call, do nothing, custom OnError method) and only the first one is suitable. Please take this with big reservation because I am no expert but IMO: anything but closing is not thread-safe because we cannot ensure that the identity is updated before next on message is called and we don't have way to stop everything till re-authentication happens (like token refresh). I have added assertion that |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@michalvavrik I'm thinking what the user experience will be like. Lets say we authenticate with Google into a Quarkus endpoint which returns HTML page, with an option to start a chatbot. The user clicks on it and a web socket session starts, I guess in this case we have the larger HTML page with text like Lets say the session has expired. If now Alice presses on anything in the HTML page like a link to another HTML page, Quarkus may auto-refresh the session or redirect Alice to Google to re-authenticate. |
+1
It's up to the client I would say. I.e. if the connection is closed then the client (e.g. some JS code) can decide to redirect the user. |
Just curious, ideally, the user should realize that the ChatBot error related to the closed connection means it is time to refresh the surrounding HTML page |
...ebsockets-next/runtime/src/main/java/io/quarkus/websockets/next/runtime/SecuritySupport.java
Outdated
Show resolved
Hide resolved
4de8315
to
514c426
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.
Loogs good!
I agree with Martin's comments - client has to handle this. I have one idea, but it would need to be a separate issue and I don't know if it makes sense - for a code flow we know that token is going to expire and if refreshing token is possible asynchronously via WebClient POST request, we could do that when the expiration time is getting closer. However at one time right before we synchronize there would be old token (not yet expired) used by the identity and a new issued token. |
Status for workflow
|
Sure, this is what I was curious about, as long as the script can intercept this error and decide what to do, it is all good |
Status for workflow
|
This is Ok I guess, the WS session will still use valid identity until it expires, even if outside of the WS channel a new token is available... Let's discuss it further when you'd like |
Proposing a backport to 3.11 as a hardening fix, which ensures the WS session can't go forever if the identity has expired. But, @gsmet, please remove the backport label if you have some concerns about backporting it |
@mkouba done with 3.11.2 |