Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F162708
basic_auth_decoder_plug.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
844 B
Referenced Files
None
Subscribers
None
basic_auth_decoder_plug.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.Web.Plugs.BasicAuthDecoderPlug
do
@moduledoc
"""
Decodes HTTP Basic Auth information and assigns `:auth_credentials`.
NOTE: no checks are performed at this step, auth_credentials/username could be easily faked.
"""
import
Plug.Conn
def
init
(
options
)
do
options
end
def
call
(
conn
,
_opts
)
do
with
[
"Basic "
<>
header
]
<-
get_req_header
(
conn
,
"authorization"
),
{
:ok
,
userinfo
}
<-
Base
.
decode64
(
header
),
[
username
,
password
]
<-
String
.
split
(
userinfo
,
":"
,
parts
:
2
)
do
conn
|>
assign
(
:auth_credentials
,
%{
username
:
username
,
password
:
password
})
else
_
->
conn
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Fri, Feb 21, 5:42 PM (13 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
66786
Default Alt Text
basic_auth_decoder_plug.ex (844 B)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment