aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKokaKiwi <kokakiwi@kokakiwi.net>2019-06-22 19:45:21 +0200
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2019-07-06 20:29:17 +0200
commita7885748c7f37db232a097aa24132ed59229360c (patch)
tree27eb83443f82e0fd04b6c403e30406cde4aec34b
parent3589b30ddc9d0c23ca6f00264cff05e53be1b270 (diff)
downloadpleroma-a7885748c7f37db232a097aa24132ed59229360c.tar.gz
MastoAPI streaming: Replace access_token with Sec-WebSocket-Protocol
-rw-r--r--lib/pleroma/web/mastodon_api/websocket_handler.ex4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pleroma/web/mastodon_api/websocket_handler.ex b/lib/pleroma/web/mastodon_api/websocket_handler.ex
index 3299e1721..db6ae23b0 100644
--- a/lib/pleroma/web/mastodon_api/websocket_handler.ex
+++ b/lib/pleroma/web/mastodon_api/websocket_handler.ex
@@ -29,7 +29,7 @@ defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do
def init(%{qs: qs} = req, state) do
with params <- :cow_qs.parse_qs(qs),
- access_token <- List.keyfind(params, "access_token", 0),
+ access_token <- :cowboy_req.header("sec-websocket-protocol", req, 0),
{_, stream} <- List.keyfind(params, "stream", 0),
{:ok, user} <- allow_request(stream, access_token),
topic when is_binary(topic) <- expand_topic(stream, params) do
@@ -89,7 +89,7 @@ defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do
end
# Authenticated streams.
- defp allow_request(stream, {"access_token", access_token}) when stream in @streams do
+ defp allow_request(stream, access_token) when stream in @streams do
with %Token{user_id: user_id} <- Repo.get_by(Token, token: access_token),
user = %User{} <- User.get_cached_by_id(user_id) do
{:ok, user}