Restler icon indicating copy to clipboard operation
Restler copied to clipboard

Cache doesn't always include restricted endpoint resources

Open shaneneuerburg opened this issue 12 years ago • 2 comments

When using the default cache, starting with it clear, it seems to only attempt caching on the first pass. In my case, there are restricted endpoints. If I access the API with a cleared cache as a non-authenticated user, it only caches the non-authenticated endpoints.

If I then authenticate, it does not generate the resource caches for the restricted/authenticated endpoints.

However, if I clear the cache and then request the resources as an authenticated user, it creates all of the resources in the cache.

I'm digging through the source trying to find out what is causing this, or if I'm even understanding it correctly.

shaneneuerburg avatar Mar 16 '14 20:03 shaneneuerburg

From what I can see in Resources.php, my assumptions seem to be correct. It appears that it only checks for the existence of "resources" in the cache. If the first hit to resources.json is by an anonymous user, it'll cache only public endpoints. When an authenticated user then hits it, it is only returning the public endpoints that were cached.

Possible solution:

  • Cache $allRoutes in Resources.php->index()
  • Run _mapResources against the cache for every request

shaneneuerburg avatar Mar 16 '14 20:03 shaneneuerburg

Please try the RC5 release in V3 branch, which wont have this issue.

But creating unique cache files for each role of user is a responsibility of the auth class. For an example take a look at AccessControl class in Access Control example

It is calling setCacheIdentifiermethod of the user class which implements iIdentifyUser (previously called iUser in RC4) and specified with Defaults::$userIdentifierClass property

Resources class then calls getCacheIdentifier method to create unique cache files for each user type

If you still find some problem, please re-open this issue!

Arul- avatar Mar 20 '14 08:03 Arul-