projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Mix format
[akkoma]
/
lib
/
pleroma
/
web
/
plugs
/
admin_secret_authentication_plug.ex
diff --git
a/lib/pleroma/web/plugs/admin_secret_authentication_plug.ex
b/lib/pleroma/web/plugs/admin_secret_authentication_plug.ex
index ff49801f4cca8692160b90e15e835fe32a658e30..976e5cd926978fffcbf800c5b14ded5bbe2538f3 100644
(file)
--- a/
lib/pleroma/web/plugs/admin_secret_authentication_plug.ex
+++ b/
lib/pleroma/web/plugs/admin_secret_authentication_plug.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.AdminSecretAuthenticationPlug do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.AdminSecretAuthenticationPlug do
@@
-13,13
+13,6
@@
defmodule Pleroma.Web.Plugs.AdminSecretAuthenticationPlug do
options
end
options
end
- def secret_token do
- case Pleroma.Config.get(:admin_token) do
- blank when blank in [nil, ""] -> nil
- token -> token
- end
- end
-
def call(%{assigns: %{user: %User{}}} = conn, _), do: conn
def call(conn, _) do
def call(%{assigns: %{user: %User{}}} = conn, _), do: conn
def call(conn, _) do
@@
-30,7
+23,7
@@
defmodule Pleroma.Web.Plugs.AdminSecretAuthenticationPlug do
end
end
end
end
- def authenticate(%{params: %{"admin_token" => admin_token}} = conn) do
+ def
p
authenticate(%{params: %{"admin_token" => admin_token}} = conn) do
if admin_token == secret_token() do
assign_admin_user(conn)
else
if admin_token == secret_token() do
assign_admin_user(conn)
else
@@
-38,7
+31,7
@@
defmodule Pleroma.Web.Plugs.AdminSecretAuthenticationPlug do
end
end
end
end
- def authenticate(conn) do
+ def
p
authenticate(conn) do
token = secret_token()
case get_req_header(conn, "x-admin-token") do
token = secret_token()
case get_req_header(conn, "x-admin-token") do
@@
-48,6
+41,13
@@
defmodule Pleroma.Web.Plugs.AdminSecretAuthenticationPlug do
end
end
end
end
+ defp secret_token do
+ case Pleroma.Config.get(:admin_token) do
+ blank when blank in [nil, ""] -> nil
+ token -> token
+ end
+ end
+
defp assign_admin_user(conn) do
conn
|> assign(:user, %User{is_admin: true})
defp assign_admin_user(conn) do
conn
|> assign(:user, %User{is_admin: true})