diff --git a/src/emqx_app.erl b/src/emqx_app.erl index 61e30b8c9..5a55a1abd 100644 --- a/src/emqx_app.erl +++ b/src/emqx_app.erl @@ -105,13 +105,22 @@ set_special_auth_module() -> Mod -> case erlang:function_exported(Mod, check_authn, 2) of true -> + Priority = authn_module_priority(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 -> ok end end. +authn_module_priority(Mod) -> + try + Mod:authn_priority() + catch + _:_ -> + 10_000 + end. + %%-------------------------------------------------------------------- %% Print Banner %%--------------------------------------------------------------------