2020-10-31 10:38:35 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Helpers.AuthHelper do
|
|
|
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
|
|
|
|
2020-11-21 16:47:25 +00:00
|
|
|
import Plug.Conn
|
|
|
|
|
2020-10-31 10:38:35 +00:00
|
|
|
@doc """
|
|
|
|
Skips OAuth permissions (scopes) checks, assigns nil `:token`.
|
|
|
|
Intended to be used with explicit authentication and only when OAuth token cannot be determined.
|
|
|
|
"""
|
|
|
|
def skip_oauth(conn) do
|
|
|
|
conn
|
2020-11-21 16:47:25 +00:00
|
|
|
|> assign(:token, nil)
|
2020-10-31 10:38:35 +00:00
|
|
|
|> OAuthScopesPlug.skip_plug()
|
|
|
|
end
|
2020-11-21 16:47:25 +00:00
|
|
|
|
|
|
|
def drop_auth_info(conn) do
|
|
|
|
conn
|
|
|
|
|> assign(:user, nil)
|
|
|
|
|> assign(:token, nil)
|
|
|
|
end
|
2020-10-31 10:38:35 +00:00
|
|
|
end
|