summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/auth/wrapper_authenticator.ex
blob: c67082f7b3efbda8a1d6146a43c51b5f131e79fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.Auth.WrapperAuthenticator do
  @behaviour Pleroma.Web.Auth.Authenticator

  defp implementation do
    Pleroma.Config.get(
      Pleroma.Web.Auth.Authenticator,
      Pleroma.Web.Auth.PleromaAuthenticator
    )
  end

  @impl true
  def get_user(plug), do: implementation().get_user(plug)

  @impl true
  def create_from_registration(plug, registration),
    do: implementation().create_from_registration(plug, registration)

  @impl true
  def get_registration(plug), do: implementation().get_registration(plug)

  @impl true
  def handle_error(plug, error),
    do: implementation().handle_error(plug, error)

  @impl true
  def auth_template do
    # Note: `config :pleroma, :auth_template, "..."` support is deprecated
    implementation().auth_template() ||
      Pleroma.Config.get([:auth, :auth_template], Pleroma.Config.get(:auth_template)) ||
      "show.html"
  end

  @impl true
  def oauth_consumer_template do
    implementation().oauth_consumer_template() ||
      Pleroma.Config.get([:auth, :oauth_consumer_template], "consumer.html")
  end
end