aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/helpers/auth_helper.ex
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-11-25 21:47:23 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-11-25 21:47:23 +0300
commit12a5981cc3da65b7f2763d0ec05871b0986234f5 (patch)
tree8607c2d870421920cbae28dffcfcd2c63c3cb73f /lib/pleroma/helpers/auth_helper.ex
parent489b12cde48d0ed6b16914c5a831b1e992d0d059 (diff)
downloadpleroma-12a5981cc3da65b7f2763d0ec05871b0986234f5.tar.gz
Session token setting on token exchange. Auth-related refactoring.
Diffstat (limited to 'lib/pleroma/helpers/auth_helper.ex')
-rw-r--r--lib/pleroma/helpers/auth_helper.ex15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/helpers/auth_helper.ex b/lib/pleroma/helpers/auth_helper.ex
index 878fec346..392fa7d5d 100644
--- a/lib/pleroma/helpers/auth_helper.ex
+++ b/lib/pleroma/helpers/auth_helper.ex
@@ -4,9 +4,12 @@
defmodule Pleroma.Helpers.AuthHelper do
alias Pleroma.Web.Plugs.OAuthScopesPlug
+ alias Plug.Conn
import Plug.Conn
+ @oauth_token_session_key :oauth_token
+
@doc """
Skips OAuth permissions (scopes) checks, assigns nil `:token`.
Intended to be used with explicit authentication and only when OAuth token cannot be determined.
@@ -22,4 +25,16 @@ defmodule Pleroma.Helpers.AuthHelper do
|> assign(:user, nil)
|> assign(:token, nil)
end
+
+ def get_session_token(%Conn{} = conn) do
+ get_session(conn, @oauth_token_session_key)
+ end
+
+ def put_session_token(%Conn{} = conn, token) when is_binary(token) do
+ put_session(conn, @oauth_token_session_key, token)
+ end
+
+ def delete_session_token(%Conn{} = conn) do
+ delete_session(conn, @oauth_token_session_key)
+ end
end