2004-12-12 22:00:34 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% File : ejabberd_auth_external.erl
|
2007-12-24 12:41:41 +01:00
|
|
|
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
2004-12-12 22:00:34 +01:00
|
|
|
%%% Purpose : Authentification via LDAP external script
|
2007-12-24 12:41:41 +01:00
|
|
|
%%% Created : 12 Dec 2004 by Alexey Shchepin <alexey@process-one.net>
|
|
|
|
%%%
|
|
|
|
%%%
|
2009-01-12 15:44:42 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2009 ProcessOne
|
2007-12-24 12:41:41 +01:00
|
|
|
%%%
|
|
|
|
%%% This program is free software; you can redistribute it and/or
|
|
|
|
%%% modify it under the terms of the GNU General Public License as
|
|
|
|
%%% published by the Free Software Foundation; either version 2 of the
|
|
|
|
%%% License, or (at your option) any later version.
|
|
|
|
%%%
|
|
|
|
%%% This program is distributed in the hope that it will be useful,
|
|
|
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
%%% General Public License for more details.
|
2009-01-12 15:44:42 +01:00
|
|
|
%%%
|
2007-12-24 12:41:41 +01:00
|
|
|
%%% You should have received a copy of the GNU General Public License
|
|
|
|
%%% along with this program; if not, write to the Free Software
|
|
|
|
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
%%% 02111-1307 USA
|
|
|
|
%%%
|
2004-12-12 22:00:34 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
|
|
|
|
-module(ejabberd_auth_external).
|
2007-12-24 12:41:41 +01:00
|
|
|
-author('alexey@process-one.net').
|
2004-12-12 22:00:34 +01:00
|
|
|
|
|
|
|
%% External exports
|
2005-07-13 05:24:13 +02:00
|
|
|
-export([start/1,
|
2005-04-17 20:08:34 +02:00
|
|
|
set_password/3,
|
|
|
|
check_password/3,
|
|
|
|
check_password/5,
|
|
|
|
try_register/3,
|
2004-12-12 22:00:34 +01:00
|
|
|
dirty_get_registered_users/0,
|
2005-04-17 20:08:34 +02:00
|
|
|
get_vh_registered_users/1,
|
|
|
|
get_password/2,
|
|
|
|
get_password_s/2,
|
|
|
|
is_user_exists/2,
|
2004-12-12 22:00:34 +01:00
|
|
|
remove_user/2,
|
2005-04-17 20:08:34 +02:00
|
|
|
remove_user/3,
|
2004-12-12 22:00:34 +01:00
|
|
|
plain_password_required/0
|
|
|
|
]).
|
|
|
|
|
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% API
|
|
|
|
%%%----------------------------------------------------------------------
|
2005-07-13 05:24:13 +02:00
|
|
|
start(Host) ->
|
|
|
|
extauth:start(
|
|
|
|
Host, ejabberd_config:get_local_option({extauth_program, Host})),
|
2004-12-12 22:00:34 +01:00
|
|
|
ok.
|
|
|
|
|
|
|
|
plain_password_required() ->
|
|
|
|
true.
|
|
|
|
|
2005-07-13 05:24:13 +02:00
|
|
|
check_password(User, Server, Password) ->
|
2008-02-11 19:19:42 +01:00
|
|
|
extauth:check_password(User, Server, Password) andalso Password /= "".
|
2004-12-12 22:00:34 +01:00
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
check_password(User, Server, Password, _StreamID, _Digest) ->
|
|
|
|
check_password(User, Server, Password).
|
2004-12-12 22:00:34 +01:00
|
|
|
|
2005-07-13 05:24:13 +02:00
|
|
|
set_password(User, Server, Password) ->
|
2008-08-18 20:21:10 +02:00
|
|
|
case extauth:set_password(User, Server, Password) of
|
|
|
|
true -> ok;
|
|
|
|
_ -> {error, unknown_problem}
|
|
|
|
end.
|
2004-12-12 22:00:34 +01:00
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
try_register(_User, _Server, _Password) ->
|
2004-12-12 22:00:34 +01:00
|
|
|
{error, not_allowed}.
|
|
|
|
|
2008-02-19 14:49:29 +01:00
|
|
|
%% TODO
|
|
|
|
%% Return the list of all users handled by external
|
2004-12-12 22:00:34 +01:00
|
|
|
dirty_get_registered_users() ->
|
|
|
|
[].
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
get_vh_registered_users(_Server) ->
|
|
|
|
[].
|
|
|
|
|
|
|
|
get_password(_User, _Server) ->
|
2004-12-12 22:00:34 +01:00
|
|
|
false.
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
get_password_s(_User, _Server) ->
|
2004-12-12 22:00:34 +01:00
|
|
|
"".
|
|
|
|
|
2005-07-13 05:24:13 +02:00
|
|
|
is_user_exists(User, Server) ->
|
|
|
|
extauth:is_user_exists(User, Server).
|
2004-12-12 22:00:34 +01:00
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
remove_user(_User, _Server) ->
|
2004-12-12 22:00:34 +01:00
|
|
|
{error, not_allowed}.
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
remove_user(_User, _Server, _Password) ->
|
2004-12-12 22:00:34 +01:00
|
|
|
not_allowed.
|
|
|
|
|