aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_auth_external.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ejabberd_auth_external.erl')
-rw-r--r--src/ejabberd_auth_external.erl53
1 files changed, 15 insertions, 38 deletions
diff --git a/src/ejabberd_auth_external.erl b/src/ejabberd_auth_external.erl
index 6b2e2852e..c5aac836a 100644
--- a/src/ejabberd_auth_external.erl
+++ b/src/ejabberd_auth_external.erl
@@ -25,15 +25,13 @@
-module(ejabberd_auth_external).
--behaviour(ejabberd_config).
-
-author('alexey@process-one.net').
-behaviour(ejabberd_auth).
-export([start/1, stop/1, reload/1, set_password/3, check_password/4,
try_register/3, user_exists/2, remove_user/2,
- store_type/1, plain_password_required/1, opt_type/1]).
+ store_type/1, plain_password_required/1]).
-include("logger.hrl").
@@ -55,27 +53,27 @@ store_type(_) -> external.
check_password(User, AuthzId, Server, Password) ->
if AuthzId /= <<>> andalso AuthzId /= User ->
- false;
+ {nocache, false};
true ->
check_password_extauth(User, AuthzId, Server, Password)
end.
set_password(User, Server, Password) ->
case extauth:set_password(User, Server, Password) of
- Res when is_boolean(Res) -> ok;
+ Res when is_boolean(Res) -> {cache, {ok, Password}};
{error, Reason} -> failure(User, Server, set_password, Reason)
end.
try_register(User, Server, Password) ->
case extauth:try_register(User, Server, Password) of
- true -> ok;
- false -> {error, not_allowed};
+ true -> {cache, {ok, Password}};
+ false -> {cache, {error, not_allowed}};
{error, Reason} -> failure(User, Server, try_register, Reason)
end.
user_exists(User, Server) ->
case extauth:user_exists(User, Server) of
- Res when is_boolean(Res) -> Res;
+ Res when is_boolean(Res) -> {cache, Res};
{error, Reason} -> failure(User, Server, user_exists, Reason)
end.
@@ -83,46 +81,25 @@ remove_user(User, Server) ->
case extauth:remove_user(User, Server) of
false -> {error, not_allowed};
true -> ok;
- {error, Reason} -> failure(User, Server, remove_user, Reason)
+ {error, Reason} ->
+ {_, Err} = failure(User, Server, remove_user, Reason),
+ Err
end.
check_password_extauth(User, _AuthzId, Server, Password) ->
if Password /= <<"">> ->
case extauth:check_password(User, Server, Password) of
- Res when is_boolean(Res) -> Res;
+ Res when is_boolean(Res) -> {cache, Res};
{error, Reason} ->
- failure(User, Server, check_password, Reason),
- false
+ {Tag, _} = failure(User, Server, check_password, Reason),
+ {Tag, false}
end;
true ->
- false
+ {nocache, false}
end.
--spec failure(binary(), binary(), atom(), any()) -> {error, db_failure}.
+-spec failure(binary(), binary(), atom(), any()) -> {nocache, {error, db_failure}}.
failure(User, Server, Fun, Reason) ->
?ERROR_MSG("External authentication program failed when calling "
"'~s' for ~s@~s: ~p", [Fun, User, Server, Reason]),
- {error, db_failure}.
-
-opt_type(extauth_cache) ->
- ?WARNING_MSG("option 'extauth_cache' is deprecated and has no effect, "
- "use authentication or global cache configuration "
- "options: auth_use_cache, auth_cache_life_time, "
- "use_cache, cache_life_time, and so on", []),
- fun (false) -> false;
- (I) when is_integer(I), I >= 0 -> I
- end;
-opt_type(extauth_instances) ->
- ?WARNING_MSG("option 'extauth_instances' is deprecated and has no effect, "
- "use 'extauth_pool_size'", []),
- fun (V) when is_integer(V), V > 0 -> V end;
-opt_type(extauth_program) ->
- fun (V) -> binary_to_list(iolist_to_binary(V)) end;
-opt_type(extauth_pool_name) ->
- fun (V) -> iolist_to_binary(V) end;
-opt_type(extauth_pool_size) ->
- fun(I) when is_integer(I), I>0 -> I end;
-opt_type(_) ->
- [extauth_program, extauth_pool_size, extauth_pool_name,
- %% Deprecated:
- extauth_cache, extauth_instances].
+ {nocache, {error, db_failure}}.