aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Paitrault <freyskeyd@gmail.com>2022-03-24 17:03:50 +0100
committerGitHub <noreply@github.com>2022-03-24 17:03:50 +0100
commit68762146d72636acd5037cfa24babd979c6beba5 (patch)
tree24d807d56d725eb69a2369e21a643458a257baad /src
parentAdd TLS certificate authentication for MQTT connections (diff)
Checking users is active in SM for JWT authenticated user (#3795)
Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/ejabberd_auth_jwt.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ejabberd_auth_jwt.erl b/src/ejabberd_auth_jwt.erl
index caa2ddbf2..f38600bc7 100644
--- a/src/ejabberd_auth_jwt.erl
+++ b/src/ejabberd_auth_jwt.erl
@@ -85,7 +85,14 @@ check_password(User, AuthzId, Server, Token) ->
end
end.
-user_exists(_User, _Host) -> {nocache, false}.
+user_exists(User, Host) ->
+ %% Checking that the user has an active session
+ %% If the session was negociated by the JWT auth method then we define that the user exists
+ %% Any other cases will return that the user doesn't exist
+ {nocache, case ejabberd_sm:get_user_info(User, Host) of
+ [{_, Info}] -> proplists:get_value(auth_module, Info) == ejabberd_auth_jwt;
+ _ -> false
+ end}.
use_cache(_) ->
false.