25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-13 15:16:49 +02:00

New option pam_userinfotype to provide username or JID (EJAB-652)

This commit is contained in:
Badlop 2010-05-07 22:34:59 +02:00
parent 25e4038623
commit 39119192a1
3 changed files with 23 additions and 2 deletions

View File

@ -1100,6 +1100,10 @@ PAM authentication is disabled by default, so you have to configure and compile
<B><TT>{pam_service, Name}</TT></B></DT><DD CLASS="dd-description">This option defines the PAM service name.
Default is <TT>"ejabberd"</TT>. Refer to the PAM documentation of your operation system
for more information.
</DD><DT CLASS="dt-description"><B><TT>{pam_userinfotype, username|jid}</TT></B></DT><DD CLASS="dd-description">
This option defines what type of information about the user ejabberd
provides to the PAM service: only the username, or the user JID.
Default is <TT>username</TT>.
</DD></DL><P>Example:
</P><PRE CLASS="verbatim">{auth_method, [pam]}.
{pam_service, "ejabberd"}.

View File

@ -1298,6 +1298,10 @@ Options:
\titem{\{pam\_service, Name\}}\ind{options!pam\_service}This option defines the PAM service name.
Default is \term{"ejabberd"}. Refer to the PAM documentation of your operation system
for more information.
\titem{\{pam\_userinfotype, username|jid\}}\ind{options!pam\_userinfotype}
This option defines what type of information about the user ejabberd
provides to the PAM service: only the username, or the user JID.
Default is \term{username}.
\end{description}
Example:

View File

@ -60,7 +60,11 @@ check_password(User, Server, Password, _Digest, _DigestGen) ->
check_password(User, Host, Password) ->
Service = get_pam_service(Host),
case catch epam:authenticate(Service, User, Password) of
UserInfo = case get_pam_userinfotype(Host) of
username -> User;
jid -> User++"@"++Host
end,
case catch epam:authenticate(Service, UserInfo, Password) of
true -> true;
_ -> false
end.
@ -84,7 +88,11 @@ get_password_s(_User, _Server) ->
%% TODO: Improve this function to return an error instead of 'false' when connection to PAM failed
is_user_exists(User, Host) ->
Service = get_pam_service(Host),
case catch epam:acct_mgmt(Service, User) of
UserInfo = case get_pam_userinfotype(Host) of
username -> User;
jid -> User++"@"++Host
end,
case catch epam:acct_mgmt(Service, UserInfo) of
true -> true;
_ -> false
end.
@ -106,3 +114,8 @@ get_pam_service(Host) ->
undefined -> "ejabberd";
Service -> Service
end.
get_pam_userinfotype(Host) ->
case ejabberd_config:get_local_option({pam_userinfotype, Host}) of
undefined -> username;
Type -> Type
end.