mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-30 16:36:29 +01:00
Fix cyrsasl_oauth:mech_new call
This commit is contained in:
parent
1578f17eff
commit
4fce1a17d7
@ -27,11 +27,11 @@
|
|||||||
|
|
||||||
-author('alexey@process-one.net').
|
-author('alexey@process-one.net').
|
||||||
|
|
||||||
-export([start/1, stop/0, mech_new/6, mech_step/2, parse/1]).
|
-export([start/1, stop/0, mech_new/4, mech_step/2, parse/1]).
|
||||||
|
|
||||||
-behaviour(cyrsasl).
|
-behaviour(cyrsasl).
|
||||||
|
|
||||||
-record(state, {host, is_user_exists}).
|
-record(state, {host}).
|
||||||
|
|
||||||
start(_Opts) ->
|
start(_Opts) ->
|
||||||
cyrsasl:register_mechanism(<<"X-OAUTH2">>, ?MODULE, plain),
|
cyrsasl:register_mechanism(<<"X-OAUTH2">>, ?MODULE, plain),
|
||||||
@ -39,15 +39,12 @@ start(_Opts) ->
|
|||||||
|
|
||||||
stop() -> ok.
|
stop() -> ok.
|
||||||
|
|
||||||
mech_new(Host, _GetPassword, _CheckPassword, _CheckPasswordDigest,
|
mech_new(Host, _GetPassword, _CheckPassword, _CheckPasswordDigest) ->
|
||||||
IsUserExists, _ClientCertFile) ->
|
{ok, #state{host = Host}}.
|
||||||
{ok, #state{host = Host, is_user_exists = IsUserExists}}.
|
|
||||||
|
|
||||||
mech_step(State, ClientIn) ->
|
mech_step(State, ClientIn) ->
|
||||||
case prepare(ClientIn) of
|
case prepare(ClientIn) of
|
||||||
[AuthzId, User, Token] ->
|
[AuthzId, User, Token] ->
|
||||||
case (State#state.is_user_exists)(User) of
|
|
||||||
true ->
|
|
||||||
case ejabberd_oauth:check_token(
|
case ejabberd_oauth:check_token(
|
||||||
User, State#state.host, <<"sasl_auth">>, Token) of
|
User, State#state.host, <<"sasl_auth">>, Token) of
|
||||||
true ->
|
true ->
|
||||||
@ -57,8 +54,6 @@ mech_step(State, ClientIn) ->
|
|||||||
false ->
|
false ->
|
||||||
{error, <<"not-authorized">>, User}
|
{error, <<"not-authorized">>, User}
|
||||||
end;
|
end;
|
||||||
_ -> {error, <<"not-authorized">>, User}
|
|
||||||
end;
|
|
||||||
_ -> {error, <<"bad-protocol">>}
|
_ -> {error, <<"bad-protocol">>}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user