aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_auth.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ejabberd_auth.erl')
-rw-r--r--src/ejabberd_auth.erl26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl
index bf47af85b..343ad9436 100644
--- a/src/ejabberd_auth.erl
+++ b/src/ejabberd_auth.erl
@@ -5,7 +5,7 @@
%%% Created : 23 Nov 2002 by Alexey Shchepin <alexey@process-one.net>
%%%
%%%
-%%% ejabberd, Copyright (C) 2002-2015 ProcessOne
+%%% ejabberd, Copyright (C) 2002-2016 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
@@ -27,6 +27,8 @@
-module(ejabberd_auth).
+-behaviour(ejabberd_config).
+
-author('alexey@process-one.net').
%% External exports
@@ -42,7 +44,7 @@
remove_user/2, remove_user/3, plain_password_required/1,
store_type/1, entropy/1]).
--export([auth_modules/1]).
+-export([auth_modules/1, opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
@@ -75,7 +77,7 @@
-callback get_password_s(binary(), binary()) -> binary() | {binary(), binary(), binary(), integer()}.
start() ->
-%% This is only executed by ejabberd_c2s for non-SASL auth client
+ %% This is only executed by ejabberd_c2s for non-SASL auth client
lists:foreach(fun (Host) ->
lists:foreach(fun (M) -> M:start(Host) end,
auth_modules(Host))
@@ -116,7 +118,7 @@ check_password(User, AuthzId, Server, Password) ->
%% true | false
-spec check_password(binary(), binary(), binary(), binary(), binary(),
fun((binary()) -> binary())) -> boolean().
-
+
check_password(User, AuthzId, Server, Password, Digest,
DigestGen) ->
case check_password_with_authmodule(User, AuthzId, Server,
@@ -185,7 +187,8 @@ try_register(User, Server, Password) ->
case is_user_exists(User, Server) of
true -> {atomic, exists};
false ->
- case lists:member(jlib:nameprep(Server), ?MYHOSTS) of
+ LServer = jid:nameprep(Server),
+ case lists:member(LServer, ?MYHOSTS) of
true ->
Res = lists:foldl(fun (_M, {atomic, ok} = Res) -> Res;
(M, _) ->
@@ -355,7 +358,7 @@ remove_user(User, Server) ->
lists:foreach(fun (M) -> M:remove_user(User, Server)
end,
auth_modules(Server)),
- ejabberd_hooks:run(remove_user, jlib:nameprep(Server),
+ ejabberd_hooks:run(remove_user, jid:nameprep(Server),
[User, Server]),
ok.
@@ -373,7 +376,7 @@ remove_user(User, Server, Password) ->
error, auth_modules(Server)),
case R of
ok ->
- ejabberd_hooks:run(remove_user, jlib:nameprep(Server),
+ ejabberd_hooks:run(remove_user, jid:nameprep(Server),
[User, Server]);
_ -> none
end,
@@ -424,7 +427,7 @@ auth_modules() ->
%% Return the list of authenticated modules for a given host
auth_modules(Server) ->
- LServer = jlib:nameprep(Server),
+ LServer = jid:nameprep(Server),
Default = case gen_mod:default_db(LServer) of
mnesia -> internal;
DBType -> DBType
@@ -453,3 +456,10 @@ import(Server, riak, Passwd) ->
ejabberd_auth_riak:import(Server, riak, Passwd);
import(_, _, _) ->
pass.
+
+opt_type(auth_method) ->
+ fun (V) when is_list(V) ->
+ true = lists:all(fun is_atom/1, V), V;
+ (V) when is_atom(V) -> [V]
+ end;
+opt_type(_) -> [auth_method].