-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache behavior for topics that are constantly active within the cache expiration time #100
Comments
@arctic-alpaca Indeed, the cache is refreshed because it aims for the case of say having topics published with a frequency of ~15 seconds +- a couple of seconds, you can avoid having to hit your underlying store every couple of messages by setting the expiration to something slightly higher than that, ensuring quick availability for your frequent cases while not automatically granting for the less common ones. But I see the need for a more general cache that just grants access for some period of time without refreshing, so thanks for bringing it up. Off the top of my head I'm thinking in options such as |
While this does reduce load on the backend significantly, it also introduces a, in my opinion, quite problematic security issue. This behavior prevents an admin from revoking access to any user who publishes/receives messages with a frequency higher than the cache expiration. At least without restarting the service with I think the best approach would be to change the default behavior to let cache entries time out regardless of acivity and to introduce options to modify this behavior backend specific. For example the current behavior could be desired for ACL and password files, but is probably not desired for databases used to grant and revoke access dynamically. |
@arctic-alpaca Yeah, I know there's a security issue in the approach, was asking more about what you were envisioning besides that. Having per backend options is very tricky and only possible when using prefixes, otherwise we don't know which backend options we should look at to refresh the cache or not. Let's keep it simple for now and just add an |
I'm not sure having a security issue in the default settings is the right aproach. To put it bluntly, my expectations when using a cache don't include being unable to revoke access in some scenarios. If you don't want to default |
@arctic-alpaca After some thought, yeah, you're right: let's play it safe and default to not refreshing records. |
I'm glad you decided this way, thank you very much for your quick response and your work on this plugin! The PR looks good to me, but I'm not familiar with Go. |
Hello,
I'm using version 1.0.0 of this plugin and version 1.14.15 of Mosquitto in a docker container on a Raspberry Pi with redis as cache.
The plugin is used for authentication and authorization with the ChirpStack.
I noticed, when testing with very frequent published messages, that the cache doesn't expire even though cache expiration is set.
I'm not familiar with go, but I think this is caused by this function:
mosquitto-go-auth/cache/cache.go
Line 212 in 4b20bb3
Every cache hit refreshes the expiration date. This leads to cache entries never getting removed even if the backend removes the entry.
Is this intended? I think the cache should expire regardless of activity.
The text was updated successfully, but these errors were encountered: