-
Hello, we issue a JWT token in a 3rd party application (our central user management platform - However, the real payload of our JWT issued in the user platform is following: {
"id": "longuseridstring",
"role": "rolestring",
"app_access": true,
"admin_access": false,
"iat": 1666725952,
"exp": 1666726852,
"iss": "directus"
} So basically the user identifier has (obviously) not {
"id": "longuseridstring@hostname"
} and Question: We use websocket and javascript to login the user from frontend. ejabberd version 22.5.0 Thanks for your support! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I can think a very simple and which patch would be something like this. But, as it doesn't check the server, it would allow this token to be used to login to username "longuseridstring" in any of the local hosts: diff --git a/src/ejabberd_auth_jwt.erl b/src/ejabberd_auth_jwt.erl
index d1fe4d15a..1c93d3410 100644
--- a/src/ejabberd_auth_jwt.erl
+++ b/src/ejabberd_auth_jwt.erl
@@ -106,7 +106,11 @@ check_decoded_jwt(true, Fields, _Signature, Server, User) ->
{ok, SJid} when is_binary(SJid) ->
try
JID = jid:decode(SJid),
- JID#jid.luser == User andalso JID#jid.lserver == Server
+ case {JID#jid.luser, JID#jid.lserver} of
+ {User, Server} -> true; % jid = user@server
+ {<<"">>, User} -> true; % jid = user
+ _ -> false
+ end
catch error:{bad_jid, _} ->
false
end; |
Beta Was this translation helpful? Give feedback.
I can think a very simple and which patch would be something like this. But, as it doesn't check the server, it would allow this token to be used to login to username "longuseridstring" in any of the local hosts: