Skip to content

Change WebSocket auth #12

@Brayan-724

Description

@Brayan-724

Due to the WebSocket API in the browsers doesn't allow to add custom headers in the request, the JWT cannot be got from Authorization and should change.

Browsers allow to send custom info from a specific header Sec-WebSocket-Protocol that contains arbitrary data, and we can use it to send de jwt, this is not a very hacky thing because browser doesn't allow other way. ref: kubernetes

So the implementation should change to the following:

  • Extract Sec-WebSocket-Protocol
  • Split (limit: 5 *[1]) parameters by , (comma)
  • Split (limit: 1) key-value parameters by = (equal)
  • Get auth key

*[1] If we don't use limit it can be used as exploit, we don't expect more than 5 params, but it can be change if needed

All the parameters can be collected to Vec<(String, String)> instead of HashMap.

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions