Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F21907160
auth_helper.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
auth_helper.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
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.
"""
def
skip_oauth
(
conn
)
do
conn
|>
assign
(
:token
,
nil
)
|>
OAuthScopesPlug
.
skip_plug
()
end
@doc
"Drops authentication info from connection"
def
drop_auth_info
(
conn
)
do
# To simplify debugging, setting a private variable on `conn` if auth info is dropped
conn
|>
assign
(
:user
,
nil
)
|>
assign
(
:token
,
nil
)
|>
put_private
(
:authentication_ignored
,
true
)
end
@doc
"Gets OAuth token string from session"
def
get_session_token
(%
Conn
{}
=
conn
)
do
get_session
(
conn
,
@oauth_token_session_key
)
end
@doc
"Updates OAuth token string in session"
def
put_session_token
(%
Conn
{}
=
conn
,
token
)
when
is_binary
(
token
)
do
put_session
(
conn
,
@oauth_token_session_key
,
token
)
end
@doc
"Deletes OAuth token string from session"
def
delete_session_token
(%
Conn
{}
=
conn
)
do
delete_session
(
conn
,
@oauth_token_session_key
)
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sun, Dec 28, 1:41 AM (11 h, 40 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
722582
Default Alt Text
auth_helper.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment