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(websocket): add process to authenticate websocket connections #1921

Merged
merged 1 commit into from
Sep 24, 2021

Commits on Sep 24, 2021

  1. feat(websocket): scope websocket connections

    Websocket connections need to be scoped so we only send the relevant events to the correct connections.
    
    To accomplish this, we keep track of the profile.ID of each connections using the new `websocket.conn` struct, as well as keeping a map of profile.IDs to connections.
    
    To allow us to authenticate tokens, the `websocket.Handler` must have access to the `key.Store`.
    
    We've added an authentication handshake. Once the connection has been established, the client can request to "subscribe" to a connection, and send over a token as part of the message payload. If that token is valid, we upgrade the connection, and send over a success message. If not, we send over a failure message.
    
    If the client wants to unsubscribe, they send over an "unsubscribe" request. This will remove the association between that connection and a profile.ID. It will not close the connection.
    
    We've also defined a `websocket.message` struct that the websocket expects to receive for communication about the state of the websocket connection (namely the authentication handshake).
    ramfox committed Sep 24, 2021
    Configuration menu
    Copy the full SHA
    ef8110e View commit details
    Browse the repository at this point in the history