-
Notifications
You must be signed in to change notification settings - Fork 59
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
New feature: Support resource caching #67
Comments
That's a good question. I've been wondering what would a good strategy around the caching behavior look like. Correct me if I'm mistaken, but wouldn't the first time resources are fetched (and then cached) be ran though the authorization properly? As in, one visitor would trigger the authorizations and then subsequent visitors would just use the cache as-is, as the authorizations had already been ran once? I'm just pondering on what kinds of authorization leaks would be possible if we didn't authorize for cached resources 🤔. A poisoned cache with e.g. admin-only visible resources have a real possibility of being visible to normal visitors that way. These things are hopefully known to people who do enable caching, and act accordingly. I haven't really looked into how JR does caching. Do you know how JR caches things that can vary based on who is fetching the resources? Would there be a way for us to warn or error if an invalid configuration were to be used? Or provide some sort of guidance that users won't accidentally cause authorization leaks? We should probably skip authorization on cached objects. However, it would be crucial to do that in a way that would be documented properly and if possible, we'd guide developers to design their caching strategy with authorization in mind, automatically. |
You're correct, this could depend on how the cache key is built. However, now that I more thought about it, you would better off with simplest keys possible to increase the reusability of the cached object. Giving that, I think it would be safest to actually authorize each cached resource. If the resource is cached properly the authorization process shouldn't trigger any extra query. @valscion do you think it would be possible to update the logic to not depends on the |
I haven't looked into how the code over at If you're able to fiddle around and create some sort of proof of concept about authorizing cached resources, we could have something concrete to talk about |
Ok, thanks for the feedback. I agree that not going without the |
Bump. I'd love caching support for this gem. I don't mind having potentially lots of cache keys (i.e. combining the |
Great @joshkinabrew! Would you be willing to devote some time to come up with a proof of concept for this? This was my comment before, and it still applies:
I am open to helping get this implemented, but as we don't currently need the caching support at work, I don't have time to devote to this feature. |
I did some experiments with caching yesterday, but most changes that I made was in jsonapi-resources CachedResourceFragment class. I'm exposing the original model into cache, so jsonapi-authorizer works just fine for us, there is no user specific cache key at the moment as we don't currently need the that feature, but i'm going to take a look next week. |
Thanks @harisadam! Let us know how it goes |
Hi, guys! Do you have some news about this issue? |
Nope |
Hi,
While testing the 0.9 JR caching feature I encountered the following error:
JSONAPI::CachedResourceFragment
object doesn't have a_model
, should you skip authorization on cached objects?The text was updated successfully, but these errors were encountered: