iegomez / mosquitto-go-auth

Auth plugin for mosquitto.
MIT License
519 stars 170 forks source link

jwt no information is sent to the endpoints #330

Closed Phoenix3232 closed 1 month ago

Phoenix3232 commented 2 months ago

I set up authorization via jwt, but no information is sent to the endpoints in the request, except for Bearer in the headers.

image image
iegomez commented 1 month ago

Sorry but that's not enough to tell you anything about your issue, which I guess it's not related to the plugin but to whatever setup you have on your receiving end, so I'd advise to check that first.

Phoenix3232 commented 1 month ago

I wrote a simple test script that writes the entire request ($_REQUEST) and the body of the php://input request to a file. If I switch the JWT mode to HTTP mode, everything works correctly and I can see the request without changing the endpoint code.

iegomez commented 1 month ago

Sorry, but again, I don't see how I can help you here, I can't externally debug your issue. Set the log level to debug, monitor http traffic, etc., and see what's going on.

Phoenix3232 commented 1 month ago

An empty request comes in, there is no data in the request body, nor in POST\GET\PUT If you switch to mode=HTTP, then everything works. The problem is definitely in mode=JWT

iegomez commented 1 month ago

An empty request could mean anything, e.g. a proxy is stripping it, I can't say anything from the description. If you get some logs, I could do something; otherwise, it's on you to debug.

iegomez commented 1 month ago

Also, I'm assuming your issue is with the ACL endpoint, because if it's the user endpoint, then please check the readme as you're seeing exactly what's expected to happen:

*Important*: Please note that when using JWT, username and password are not needed, so for user and superuser check the backend will send an empty string or empty form values. On the other hand, all three cases will set the "authorization" header with the jwt token, which mosquitto will pass to the plugin as the regular "username" param.
Phoenix3232 commented 1 month ago

No, the problem is with the ACL endpoint. In jwt mode it receives an empty request, although in http mode it receives the correct json. There are no restrictions on my part, just connect the empty request in jwt mode

iegomez commented 1 month ago

You won't get a json with your configuration though, you set the option auth_opt_jwt_params_mode form.

Phoenix3232 commented 1 month ago

I tried both the form and json options. No difference. I repeat that there is a script on the end station that writes all requests to it (GET, POST) + the request body to a file. In jwt mode, emptiness comes, and in http mode, everything is fine

iegomez commented 1 month ago

I understand that, but what do you want me to do without any logs or anything?

Phoenix3232 commented 1 month ago

I sent you the endpoint given, in which it is worth writing the entire request to it into a file. It is empty. Why does everything work in http mode, but in jwt mode nothing works on some endpoints and addresses?

Can you check the operation of your device in this mode yourself?

image
iegomez commented 1 month ago

No, sorry, I'm at work and can't debug this for you. If you can show me an actual issue via logs or whatever proves there's a bug, then we can be certain and I can work on fixing it. Otherwise, I'd be hunting blindly for something that might not even be a problem in the plugin.

Phoenix3232 commented 1 month ago

I showed you the endpoint log. What other logs could there be? If the problem was on my side or in the endpoint, then the http mode wouldn't work either.

iegomez commented 1 month ago

Mosquitto + plugin logs, actual http traffic logs, something that gives information. You can even add your own logs, recompile the plugin and see what's getting sent. You showed me an image with a bunch of Array() lines, that tells me nothing.

iegomez commented 1 month ago

@Phoenix3232 let me know if you get any logs or if you already resolved the problem to see if I keep this issue open or close it.