yokomizor / ejabberd-auth-jwt

:speech_balloon: Ejabberd authentication module using JWT tokens
Apache License 2.0
5 stars 2 forks source link

Unable to connect to server, receiving Invalid username or password response #3

Closed sheuertz closed 5 years ago

sheuertz commented 6 years ago

Hi,

I'm trying to incorporate your module into ejabberd. It shows as installed, and the auth_mode is set to jwt. To test the connection, I'm using a simple JWT created on http://jwtbuilder.jamiekurtz.com/. I'm just using the HS256 default secret on that site when generating the JWT.

I am trying to connect using Pidgin. I set the username to match the sub claim, and the password to the token, but when it tries to connect, I get an Invalid username or password message.

15:22:14.378 [info] (tls|<0.734.0>) Failed c2s PLAIN authentication for jrocket@example.com from ...

I can see in the log that the token is getting to the server, but I can't tell if the jwt auth module is being used to authenticate. Is there any guidance you can give if I'm doing something wrong based on the above?

yokomizor commented 5 years ago

Hi,

Sorry it took so long to answer. I suppose you found a solution by now, but I will post this anyway to help future users.

The HS256 key attribute was expecting a base64 encoded key. This was not very well documented. I just changed this behaviour:

https://github.com/yokomizor/ejabberd-auth-jwt/commit/e80a3ae300a68c4f288685efc60a7864b20d0f32#diff-6d9d5cd5f19344fb1c266c579f878716R116

Before

jwtauth_key: "U0VDUkVU" # Base64 encoded key
jwtauth_strict_alg: "HS256"

Now:

auth_method: jwt
modules:
  ejabberd_auth_jwt:
    key: "SECRET" 
    strict_alg: "HS256"