a077cfa416abad89d478cefea07266895af40fb6
[anni] / lib / pleroma / web / auth / wrapper_authenticator.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.Auth.WrapperAuthenticator do
6   @behaviour Pleroma.Web.Auth.Authenticator
7
8   defp implementation do
9     Pleroma.Config.get(
10       Pleroma.Web.Auth.Authenticator,
11       Pleroma.Web.Auth.PleromaAuthenticator
12     )
13   end
14
15   @impl true
16   def get_user(plug), do: implementation().get_user(plug)
17
18   @impl true
19   def create_from_registration(plug, registration),
20     do: implementation().create_from_registration(plug, registration)
21
22   @impl true
23   def get_registration(plug), do: implementation().get_registration(plug)
24
25   @impl true
26   def handle_error(plug, error),
27     do: implementation().handle_error(plug, error)
28
29   @impl true
30   def auth_template do
31     # Note: `config :pleroma, :auth_template, "..."` support is deprecated
32     implementation().auth_template() ||
33       Pleroma.Config.get([:auth, :auth_template], Pleroma.Config.get(:auth_template)) ||
34       "show.html"
35   end
36
37   @impl true
38   def oauth_consumer_template do
39     implementation().oauth_consumer_template() ||
40       Pleroma.Config.get([:auth, :oauth_consumer_template], "consumer.html")
41   end
42 end