1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Auth.Authenticator do
6 alias Pleroma.Registration
11 Pleroma.Web.Auth.Authenticator,
12 Pleroma.Web.Auth.PleromaAuthenticator
16 @callback get_user(Plug.Conn.t(), Map.t()) :: {:ok, User.t()} | {:error, any()}
17 def get_user(plug, params), do: implementation().get_user(plug, params)
19 @callback create_from_registration(Plug.Conn.t(), Map.t(), Registration.t()) ::
20 {:ok, User.t()} | {:error, any()}
21 def create_from_registration(plug, params, registration),
22 do: implementation().create_from_registration(plug, params, registration)
24 @callback get_registration(Plug.Conn.t(), Map.t()) ::
25 {:ok, Registration.t()} | {:error, any()}
26 def get_registration(plug, params),
27 do: implementation().get_registration(plug, params)
29 @callback handle_error(Plug.Conn.t(), any()) :: any()
30 def handle_error(plug, error), do: implementation().handle_error(plug, error)
32 @callback auth_template() :: String.t() | nil
34 # Note: `config :pleroma, :auth_template, "..."` support is deprecated
35 implementation().auth_template() ||
36 Pleroma.Config.get([:auth, :auth_template], Pleroma.Config.get(:auth_template)) ||
40 @callback oauth_consumer_template() :: String.t() | nil
41 def oauth_consumer_template do
42 implementation().oauth_consumer_template() ||
43 Pleroma.Config.get([:auth, :oauth_consumer_template], "consumer.html")