1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-05 19:42:11 +02:00

feat: support loading Elixir modules for auth

Allow to specify an Elixir module name in `auth_method`.

If the referenced module, `M`,  cannot be loaded as `ejabberd_auth_M`,
try to load it as `Elixir.M`.
This commit is contained in:
Marcos de Vera Piquero 2024-11-22 08:30:55 +01:00
parent 715b5b64c6
commit 17b5b34e3c
4 changed files with 58 additions and 5 deletions

View file

@ -0,0 +1,39 @@
defmodule ModAuthExample do
@moduledoc """
This is a dummy auth module to demonstrate the usage of Elixir to
create Ejabberd Auth modules.
"""
import Ejabberd.Logger
@behaviour :ejabberd_auth
@impl true
def start(host) do
info("Using mod_auth_example to authenticate #{host} users")
nil
end
@impl true
def stop(host) do
info("Stop using mod_auth_example to authenticate #{host} users")
nil
end
@impl true
def check_password("alice", _authz_id, _host, "secret"), do: {:nocache, true}
def check_password(_username, _authz_id, _host, _secret), do: {:nocache, false}
@impl true
def user_exists("alice", _host), do: {:nocache, true}
def user_exists(_username, _host), do: {:nocache, false}
@impl true
def plain_password_required(_binary), do: true
@impl true
def store_type(_host), do: :external
@impl true
def use_cache(_host), do: false
end