Private
Public Access
Purge the PWA page cache on every login/logout/expiry transition (R2-S3, #35)
The service worker cached authenticated pages in one origin-wide cache and only purged it when the logout request itself passed through it — not on session expiry, externally cleared cookies, or an account switch, so a shared device could show the previous session's pages offline. Every HTML response now carries X-Evection-Auth: an opaque HMAC of the user (or "anon"), via a small middleware. The service worker remembers the marker its cached pages belong to and, whenever a navigation brings a different one, deletes the pages cache before storing anything; "anon" responses (the login page) are never cached. So the cache always holds exactly one session's pages, and any transition the worker can observe online clears it. (What no design can detect is a session ending while the device stays offline.) Verified in a real browser: pages cached after login; expiring the session server-side (no logout request) and loading a page left the cache deleted and the marker "anon"; logging in as a second user afterward cached only that user's pages, none of the first user's. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
91a4c360a4
commit
aacb41d1d3
4 files changed
+107
-3
No files matched your search
@@ -49,6 +49,7 @@ MIDDLEWARE = [
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"django_htmx.middleware.HtmxMiddleware",
|
||||
"apps.accounts.middleware.SetupWizardMiddleware",
|
||||
"apps.pwa.middleware.AuthMarkerMiddleware",
|
||||
]
|
||||
|
||||
ROOT_URLCONF = "config.urls"
|
||||
|
||||
Reference in new issue
Block a user