iegomez / mosquitto-go-auth

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

Is it cache the false ACL result #278

Open eydonmlau opened 1 year ago

eydonmlau commented 1 year ago

Hi, I use the cache setting like:

auth_opt_cache true
auth_opt_cache_type go-cache
auth_opt_cache_reset true
auth_opt_cache_refresh true

When ACL check is not pass, it would cache all the same like the pass way, Is it correct? I checked the code, found the code like this:

checkACL
You can imagine a scenario, The first time a gateway(mqtt client) didn't add to application platform, and the acl would not ok first, then the gateway is added to the application platform by user, but acl also would not pass because of the cache. And if the flag `auth_opt_cache_refresh` was setted, it would never  be ok. I feel that this logic is not in line with practical applications. 
In this case, what should I do ? may be set the flag `auth_opt_cache_refresh=false` is the only thing to prevent this case?

best wishes~

iegomez commented 1 year ago

Yeah, I think you need to disable refreshment altogether or handle it in the connecting side to do an exponential backoff to break the cache seconds you set in order to suit your use case. If you have a better idea, I'm all ears.

Cheers!