-
Notifications
You must be signed in to change notification settings - Fork 11
Security for WebSockets #77
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
base: main
Are you sure you want to change the base?
Conversation
bluesky_httpserver/authentication.py
Outdated
| auth_header = websocket.headers.get("Authorization", "") | ||
| access_token, api_key = None, None | ||
| if auth_header.startswith("Bearer "): | ||
| access_token = auth_header[len("Bearer") :].strip() |
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.
For what it's worth, we chose not to support these in Tiled because there is no mechanism for the server to request that they be refreshed, since it cannot send HTTP response codes.
Instead, the client mints a short-lived API key and revokes it after the connection is formed.
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.
This makes sense. It should be possible to implement a refresh scheme when a token is validated by sending a plain HTTP request in case connection to a websocket fails and then refreshed if requested by the server, but it does not look like a standard approach.
Implementation of websocket security. The clients must authenticate with the server when connecting to the websocket. If authentication fails, then the connection is immediately closed. Clients can authenticate with the server using API keys. The authentication scheme is identical to the scheme used for other API endpoints. If the client is using tokens, it must request a short-lived API key from the server and use it to establish the connection. Once connection is established, the key should be revoked.
The websockets implemented in #74 are not secured. The security is added in this PR.
Summary of Changes for Release Notes
Added
How Has This Been Tested?
Unit tests were added.