2019-02-26 13:26:54 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-02-28 11:12:41 +00:00
|
|
|
defmodule Pleroma.Web.Auth.Authenticator do
|
2019-02-26 12:27:01 +00:00
|
|
|
alias Pleroma.User
|
2019-03-20 07:35:31 +00:00
|
|
|
alias Pleroma.Registration
|
2019-02-26 12:27:01 +00:00
|
|
|
|
2019-02-28 10:00:54 +00:00
|
|
|
def implementation do
|
|
|
|
Pleroma.Config.get(
|
2019-02-28 11:12:41 +00:00
|
|
|
Pleroma.Web.Auth.Authenticator,
|
|
|
|
Pleroma.Web.Auth.PleromaAuthenticator
|
2019-02-28 10:00:54 +00:00
|
|
|
)
|
|
|
|
end
|
2019-02-26 12:27:01 +00:00
|
|
|
|
2019-03-15 14:08:03 +00:00
|
|
|
@callback get_user(Plug.Conn.t(), Map.t()) :: {:ok, User.t()} | {:error, any()}
|
|
|
|
def get_user(plug, params), do: implementation().get_user(plug, params)
|
|
|
|
|
2019-03-20 07:35:31 +00:00
|
|
|
@callback create_from_registration(Plug.Conn.t(), Map.t(), Registration.t()) ::
|
2019-03-15 14:08:03 +00:00
|
|
|
{:ok, User.t()} | {:error, any()}
|
2019-03-20 07:35:31 +00:00
|
|
|
def create_from_registration(plug, params, registration),
|
|
|
|
do: implementation().create_from_registration(plug, params, registration)
|
|
|
|
|
|
|
|
@callback get_registration(Plug.Conn.t(), Map.t()) ::
|
|
|
|
{:ok, Registration.t()} | {:error, any()}
|
|
|
|
def get_registration(plug, params),
|
|
|
|
do: implementation().get_registration(plug, params)
|
2019-02-26 12:27:01 +00:00
|
|
|
|
|
|
|
@callback handle_error(Plug.Conn.t(), any()) :: any()
|
2019-02-28 10:00:54 +00:00
|
|
|
def handle_error(plug, error), do: implementation().handle_error(plug, error)
|
2019-02-28 10:58:58 +00:00
|
|
|
|
|
|
|
@callback auth_template() :: String.t() | nil
|
|
|
|
def auth_template do
|
|
|
|
implementation().auth_template() || Pleroma.Config.get(:auth_template, "show.html")
|
|
|
|
end
|
2019-03-27 12:39:35 +00:00
|
|
|
|
|
|
|
@callback oauth_consumer_template() :: String.t() | nil
|
|
|
|
def oauth_consumer_template do
|
|
|
|
implementation().oauth_consumer_template() ||
|
|
|
|
Pleroma.Config.get(:oauth_consumer_template, "consumer.html")
|
|
|
|
end
|
2019-02-26 12:27:01 +00:00
|
|
|
end
|