diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-10-31 13:38:35 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-10-31 13:38:35 +0300 |
commit | 04f6b48ac1a76fe9c6c3fd573427d418bc152adf (patch) | |
tree | 8e04de0c63b91f68430a639337ce401c2b1cc9a4 /lib/pleroma/helpers | |
parent | 4fbdd1c8a12fd2b3dc6b63ccbbaa7d4241fa778e (diff) | |
download | pleroma-04f6b48ac1a76fe9c6c3fd573427d418bc152adf.tar.gz |
Auth subsystem refactoring and tweaks.
Added proper OAuth skipping for SessionAuthenticationPlug. Integrated LegacyAuthenticationPlug into AuthenticationPlug. Adjusted tests & docs.
Diffstat (limited to 'lib/pleroma/helpers')
-rw-r--r-- | lib/pleroma/helpers/auth_helper.ex | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/helpers/auth_helper.ex b/lib/pleroma/helpers/auth_helper.ex new file mode 100644 index 000000000..6e29c006a --- /dev/null +++ b/lib/pleroma/helpers/auth_helper.ex @@ -0,0 +1,17 @@ +# 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 + + @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 + |> Plug.Conn.assign(:token, nil) + |> OAuthScopesPlug.skip_plug() + end +end |