Repository navigation
Read the token untracked in TwoFactorAccessListener, so public responses stay cacheable - #327
Merged
scheb merged 1 commit intoOct 30, 2026
Conversation
…ses stay cacheable
Owner
|
Didn't know this existed! Good stuff! Thanks for including the test coverage :) Released as v8.7.0 |
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.
Hello,
With a lazy firewall,
TwoFactorAccessListenerreads the token throughsecurity.token_storageon every request. This flags the session as used and turns every response intoprivate, max-age=0, even for an anonymous visitor without session (#230).This PR injects
security.untracked_token_storageinstead, like Symfony's ownContextListenerandLazyFirewallContext. The token is still read, so the 2fa check doesn't change: a user in a 2fa process is still redirected to the 2fa form on paths without access control, unlike the change discussed in #230. Only what the application reads of the token (getUser(),is_granted()) makes the response private, as without the bundle.The test app gets a
/cacheableroute without access control:testAnonymousAccessToPathWithoutAnyAccessControlKeepsResponseCacheablefails without the fix (max-age=0, must-revalidate, private)test2faProtectsCacheablePathWithoutAnyAccessControlchecks that 2fa still protects itThanks,
Guillaume