iegomez / mosquitto-go-auth

Auth plugin for mosquitto.
MIT License
495 stars 165 forks source link

Files backend issue #291

Open yogesh-rgb opened 11 months ago

yogesh-rgb commented 11 months ago

I am using files as a backend providing all relevent configurations with all file and password file.

I am using passwor and all files as a docker mount

On broker start I have added one user able to login with that

Now I have added one more user in password file

I am not able to login, if I restart I can login with new user.

So is there a fix or how can we achieve use and all addition dynamically without restarting the broker.

Thanks in advance.

iegomez commented 11 months ago

The only way to reload static files without restart is via SIGHUP signal which is watched and intercepted here: https://github.com/iegomez/mosquitto-go-auth/blob/master/backends/files/files.go#L102C31-L102C31

Other than that, the Files backend is not meant for dynamic changes, other backends are better suited for that.

yogeshanivaln commented 11 months ago

@iegomez thanks for the response cold you please share how to achieve this with SIGHUP part

else if i use JS backend will that dynamically load the user and acl part. the examples have less info need more on how to configure them

Thanks in advance

iegomez commented 11 months ago

As far as I remember, you can send a SIGHUP like this: kill -HUP <pid>.

As for the other question, every backend that's not the static files one is dynamic in nature, e.g. your JS functions will run on each check with whatever logic they have, or the Postgres checks will query the current state of the DB which can be changed externally, etc. The Files backend could be changed to load the file on each check, but that beats the purpose: it's supposed to work exactly as Mosquitto's static files check and it's there only to support that use case along side other backends if you know some kind of users are static and won't be changing.

yogeshanivaln commented 11 months ago

HI @iegomez ,

thanks for your help on above as we are running customised docker image one quite tedious to run the HUP command

so planning to go for JS one, have few questions on it

with JS does caching works ?

Our requirent is we dont want to use any DB to save credentials so we need some kind of alterative where we can communicate with vault to get credentials instead of DB

and we will update our valut from our other bakend apis

any suggestions on above

Thanks in advance

iegomez commented 11 months ago

Caching is not tied to any specific backend, so yes, it works. Check the readme for more details on how to set it up.

iegomez commented 11 months ago

And I don't have any suggestions because that's highly dependent on your team, context, product, etc., so it could range from "sure, JS is fine" to "I'd fork or create my own implementation".

yogeshanivaln commented 11 months ago

HI @iegomez ,

thanks for your help will proceed with JS backend

as we need dynamic part so checking on otto's file reading properties