-
Notifications
You must be signed in to change notification settings - Fork 105
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
Handle websocket authentication via initial payload #915
Comments
WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible. |
Hey, thanks for opening this issue. |
Here's a draft of my implementation #918
Then I separated the initialPayload authentication from the header one, so I defined a new authenticator Now the problem is that in Can you take a look at the PR draft and share your thoughts regarding my implementation idea? Thanks! |
Fixed with #918 |
Component(s)
router
Is your feature request related to a problem? Please describe.
The Cosmo router's built-in authentication currently looks for the JWT token only in the request header. For websocket requests made from a browser, headers cannot be altered, so the token can only be sent via URL Query, Cookie, or initial payload.
Currently, if the router configuration is set to authorization >> require_authentication: true, websocket requests will receive an Unauthorized response, causing Subscriptions to fail.
Describe the solution you'd like
The Cosmo router's websocket authentication behavior needs to be updated to allow the JWT token to be acquired from the initial payload as well as the header.
@jensneuse suggested the following implementation steps on Discord:
Add a configuration option to modify WebSocket authentication behavior to allow authentication via the initial payload.
Allow configuration of the initial payload field where the auth token is located.
Modify websocket.go to consider this configuration.
Describe alternatives you've considered
No response
Additional context
I have started working on a version of authentication that also looks for the token in the initial payload. I created this feature request to further discuss the implementation steps in more detail.
Thank you! :)
The text was updated successfully, but these errors were encountered: