Closed DeveloperMarius closed 1 year ago
It seems that when I change the jwt_secret to aaaaaaaaaaasddddddddddfffff
I additionally get the following messages in the backend log:
time="2023-03-12T23:17:50Z" level=debug msg="checking auth cache for eyJ0eXAiO***************2FzdHJvdmlhLmRlIn0.Q30NGKwgucFDv-EQ*************L4bDOAM"
time="2023-03-12T23:17:50Z" level=debug msg="to auth record: [97 117 116 104 45 101 121 74 48 101 88 65 105 79 105 74 75 86 49 81 105 76 67 74 104 98 71 9********* 55 98 70 55 54 77 57 65 97 101 110 87 119 50 98 67 76 52 98 68 79 65 77 45 97 110 121 218 57 163 238 94 107 75 13 50 85 191 23*** 216 7 9]\n"
time="2023-03-12T23:17:50Z" level=debug msg="checking user eyJ0eXAiOiJKV1QiLCJhbGciO*****LmRlIn0.Q30NGKwgucFDv-EQL*********Ww2bCL4bDOAM with backend JWT"
time="2023-03-12T23:17:50Z" level=debug msg="setting auth cache for eyJ0eXAiO**********nRlY2huaWtAZ2FzdHJvdmlhLmRlIn0.Q30NGKwgucFD**********bDOAM"
time="2023-03-12T23:17:50Z" level=debug msg="to auth record: [97 117 116 104 45 101 121 74 48 101 88 65 105 79 105 74 75 86 49 81 105 76 67 74 104 98 71 99 105 79 105 74 73 *****************2 55 98 70 55 54 77 57 65 97 101 110 87 119 50 98 67 76 52 98 68 79 65 77 45 97 110 121 218 57 163 238 94 107 75 13 50 8*** 175 216 7 9]\n"
It looks like it was checking for an actual user with the jwt as the username. But I'm just clueless here^^
~ Marius
Update:
It seems that when I use a insert query as auth_opt_jwt_userquery
the ?
parameter is an empty string. Will take a deeper look at this.
~ Marius
Fixed it,
after I looked at the code in https://github.com/iegomez/mosquitto-go-auth/blob/9e9d90b676c97ec069bd39d96fa2235269f83932/backends/jwt.go#L66 I found out that when I define auth_opt_jwt_userfield
as Username
with a capital letter it will use the jwt key username
with a lower case start.
Still thank you for this plugin!
~ Marius
Hello,
first of all thank you for this plugin!
I'm trying to run a docker container with mosquitto and jwt auth, but my MQTT Explorer and clients print that the "connection was refused: Not authorized" or "The configured broker responded with unauthorized.".
My setup is the following:
docker-compose:
mosquitto.conf:
The setup works fine when I use the backend "files" but with "jwt" not. Using "files" the backend prints information about the login requests but the jwt backend does not.
When I start the container and log in I get the following:
mosquitto.log
mosquitto_backend.log
Like I sayed, not debug message in the backend log. My username is
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJVc2VybmFtZSI6ImVtYWlsQGRvbWFpbi5kZSJ9.NN_kGx9wmDaTwdjjo2TJ6JZtwdK8xoN16B2JfMjlAXI
and my passwordany
. jwt.io prints valid using the secret KR#t:K!m@HGC=[6^CbS`P~C8Q(EP.?.I really don't know why the mosquitto log prints the logout but the backend nothing about the login. I hope you can help me and thank you in advance.
~ Marius