-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support transport agnostic token passing in channels #6086
base: main
Are you sure you want to change the base?
Conversation
For WebSocket, the `Sec-WebSocket-Protocol` header is used. For LongPoll, an `Authorization` header is passed instead. Fixes #5778.
conn | ||
|> fetch_query_params() | ||
|> Transport.code_reload(endpoint, opts) | ||
|> Transport.transport_log(opts[:transport_log]) | ||
|> Transport.check_origin(handler, endpoint, opts) | ||
|> Transport.check_subprotocols(opts[:subprotocols]) | ||
|> maybe_auth_token_from_header(opts[:auth_token]) | ||
|> Transport.check_subprotocols(subprotocols) |
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.
Honestly, it feels we should just bring this function to this module and have it deal with both auth_token and subprotocols at once, or move auth_token to check subprotocols. Transport
is meant to have transport agnostic functions, and that one is clearly websockets related, so it shouldn't exist in the first place.
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.
It is part of the public API, so we can't really change it, can we?
https://hexdocs.pm/phoenix/Phoenix.Socket.Transport.html#check_subprotocols/2
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.
Yes, we cannot, but maybe we can move the auth token handling there anyway?
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.
LGTM. I have dropped a comment about subprotocol handling but it can be handled in a future PR!
For WebSocket, the
Sec-WebSocket-Protocol
header is used. For LongPoll, anAuthorization
header is passed instead.Fixes #5778.