25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Add oauth_access option

This commit is contained in:
Alexey Shchepin 2015-09-25 19:47:27 +03:00
parent 1781a58929
commit 88a206400a

View File

@ -125,11 +125,26 @@ get_client_identity(Client, Ctx) -> {ok, {Ctx, {client, Client}}}.
verify_redirection_uri(_, _, Ctx) -> {ok, Ctx}. verify_redirection_uri(_, _, Ctx) -> {ok, Ctx}.
authenticate_user({User, Server}, {password, Password} = Ctx) -> authenticate_user({User, Server}, {password, Password} = Ctx) ->
case jlib:make_jid(User, Server, <<"">>) of
#jid{} = JID ->
Access =
ejabberd_config:get_option(
{oauth_access, JID#jid.lserver},
fun(A) when is_atom(A) -> A end,
none),
case acl:match_rule(JID#jid.lserver, Access, JID) of
allow ->
case ejabberd_auth:check_password(User, Server, Password) of case ejabberd_auth:check_password(User, Server, Password) of
true -> true ->
{ok, {Ctx, {user, User, Server}}}; {ok, {Ctx, {user, User, Server}}};
false -> false ->
{error, badpass} {error, badpass}
end;
deny ->
{error, badpass}
end;
error ->
{error, badpass}
end. end.
authenticate_client(Client, Ctx) -> {ok, {Ctx, {client, Client}}}. authenticate_client(Client, Ctx) -> {ok, {Ctx, {client, Client}}}.
@ -470,4 +485,6 @@ logo() ->
opt_type(oauth_expire) -> opt_type(oauth_expire) ->
fun(I) when is_integer(I), I >= 0 -> I end; fun(I) when is_integer(I), I >= 0 -> I end;
opt_type(_) -> [oauth_expire]. opt_type(oauth_access) ->
fun(A) when is_atom(A) -> A end;
opt_type(_) -> [oauth_expire, oauth_access].