1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Plugs.BasicAuthDecoderPlug do
7 Decodes HTTP Basic Auth information and assigns `:auth_credentials`.
9 NOTE: no checks are performed at this step, auth_credentials/username could be easily faked.
18 def call(conn, _opts) do
19 with ["Basic " <> header] <- get_req_header(conn, "authorization"),
20 {:ok, userinfo} <- Base.decode64(header),
21 [username, password] <- String.split(userinfo, ":", parts: 2) do
23 |> assign(:auth_credentials, %{