feat(special_authn): set hook priority

This commit is contained in:
Thales Macedo Garitezi 2022-11-03 13:30:32 -03:00
parent f0a5208f3c
commit b71b106456
1 changed files with 10 additions and 1 deletions

View File

@ -105,13 +105,22 @@ set_special_auth_module() ->
Mod -> Mod ->
case erlang:function_exported(Mod, check_authn, 2) of case erlang:function_exported(Mod, check_authn, 2) of
true -> true ->
Priority = authn_module_priority(Mod),
persistent_term:put(special_auth_module, Mod), persistent_term:put(special_auth_module, Mod),
emqx:hook('client.authenticate', fun Mod:check_authn/2, []); emqx:hook('client.authenticate', fun Mod:check_authn/2, Priority);
false -> false ->
ok ok
end end
end. end.
authn_module_priority(Mod) ->
try
Mod:authn_priority()
catch
_:_ ->
10_000
end.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Print Banner %% Print Banner
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------