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

feat: Redirect to login on WS reconnect if auth specified #2157

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

mturoci
Copy link
Collaborator

@mturoci mturoci commented Oct 9, 2023

This PR solves the problem when websockets is not able to reconnect due to expired session. Instead of noop, it now redirects users to a login screen to renew the session.

As per WS spec:

If the status code received from the server is not 101, the client handles the response per HTTP [RFC2616] procedures. In particular, the client might perform authentication if it receives a 401 status code; the server might redirect the client using a 3xx status code (but clients are not required to follow them), etc. Otherwise, proceed as follows.

Clients (browser in our case) are not required to follow HTTP redirects, so they do not. For that reason, redirect request is sent as payload which is then handled manually.

@geomodular would you mind having a look at the code once you have time?

@mturoci mturoci requested a review from lo5 as a code owner October 9, 2023 08:54
@mturoci mturoci changed the title feat: Redirect to login on WS reconnect if auth is specified. feat: Redirect to login on WS reconnect if auth specified Oct 9, 2023
Copy link
Contributor

@geomodular geomodular left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Martin!

socket.go Show resolved Hide resolved
@mturoci mturoci merged commit 72a2a83 into main Oct 9, 2023
2 checks passed
@mturoci mturoci deleted the feat/reconnect-login-redirect branch October 9, 2023 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants