mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
New option pam_userinfotype to provide username or JID (EJAB-652)
This commit is contained in:
parent
25e4038623
commit
39119192a1
@ -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.
|
<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
|
Default is <TT>"ejabberd"</TT>. Refer to the PAM documentation of your operation system
|
||||||
for more information.
|
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:
|
</DD></DL><P>Example:
|
||||||
</P><PRE CLASS="verbatim">{auth_method, [pam]}.
|
</P><PRE CLASS="verbatim">{auth_method, [pam]}.
|
||||||
{pam_service, "ejabberd"}.
|
{pam_service, "ejabberd"}.
|
||||||
|
@ -1298,6 +1298,10 @@ Options:
|
|||||||
\titem{\{pam\_service, Name\}}\ind{options!pam\_service}This option defines the PAM service name.
|
\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
|
Default is \term{"ejabberd"}. Refer to the PAM documentation of your operation system
|
||||||
for more information.
|
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}
|
\end{description}
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@ -60,7 +60,11 @@ check_password(User, Server, Password, _Digest, _DigestGen) ->
|
|||||||
|
|
||||||
check_password(User, Host, Password) ->
|
check_password(User, Host, Password) ->
|
||||||
Service = get_pam_service(Host),
|
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;
|
true -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end.
|
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
|
%% TODO: Improve this function to return an error instead of 'false' when connection to PAM failed
|
||||||
is_user_exists(User, Host) ->
|
is_user_exists(User, Host) ->
|
||||||
Service = get_pam_service(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;
|
true -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end.
|
end.
|
||||||
@ -106,3 +114,8 @@ get_pam_service(Host) ->
|
|||||||
undefined -> "ejabberd";
|
undefined -> "ejabberd";
|
||||||
Service -> Service
|
Service -> Service
|
||||||
end.
|
end.
|
||||||
|
get_pam_userinfotype(Host) ->
|
||||||
|
case ejabberd_config:get_local_option({pam_userinfotype, Host}) of
|
||||||
|
undefined -> username;
|
||||||
|
Type -> Type
|
||||||
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user