fix(cache): send private to credentialed requests on routes without a positive ttl - #371
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #362.
A route with
ttl=0or nottlskips the backend, and the credential check was skipped together with it. Its response to anAuthorizationor session request therefore kept the decorator's plainCache-Control.@cache(ttl=0, must_revalidate=True)sentmax-age=0, must-revalidate, which RFC 9111 §3.5 lets a shared cache store and reuse for other users after revalidation.Change
private=True(which already sendsprivate),public=Trueorcache_authorized=True. A credentialed response on a non-positive-ttl route gets the sameprivateheader as on any other route, for 200 and 304:private, max-age=0, must-revalidate,privatefor a plain@cache(), andprivate, no-cachewithno_cache.WARNINGis only logged on routes that read the backend. It is about lost cache hits, which these routes never had. Each bypass is still logged atDEBUG.public/cache_authorized/privateroutes, are unchanged.Tests
tests/test_cache_bypass_private.pycovers:Authorizationon the ttl/no-ttl/no_cache variants;On master, 7 of its 12 tests fail. Removing the new warning guard fails only
test_backend_stays_untouched_and_nothing_warns.Docs: the
cache_authorizeddocstring, HTTP_CACHING and CACHE_FLOW (English and zh-TW) no longer say these routes skip the credential check. Changelog:changelog.d/362.security.md.