Repository navigation
fix: end every sign-in on admin force logout, no-store on API answers - #1495
Merged
Merged
Conversation
The admin force logout deleted the account's web sessions only. The native app's refresh token family and its paired access token survived, so the app stayed signed in for the rest of its refresh window, and the route's own comment claimed the opposite. The route now runs destroyAllSessions, the function the password change and the admin password reset already use: web sessions, native sign-ins, API tokens and the rest of credentialRevocations, then the push credentials of the devices left signed out. destroyAllSessions moves to its own module, re-exported from the session module, and reports how many web sessions and live device sign-ins it ended, for the route's answer and audit row. The confirmation text names what else stops working. An integration test drives every path that ends an account's sessions (force logout, admin reset, password change, admin and self deletion) and checks from the outside that the browser, the app's access and refresh tokens and an API token are refused and the device takes no more pushes. A guard holds every session.deleteMany to the listed places.
Most data routes sent no Cache-Control, so whether a reading, a medication list or a lab result was kept on disk was left to the browser's heuristics and to whatever proxy sits in front of the server. apiHandler now sends private, no-store (with Pragma: no-cache) on every answer that names no posture of its own. The OAuth routes and the MCP endpoint, which cannot use the wrapper, apply the same policy; the MCP transport's stream no-cache is raised to no-store. The coach and document chat streams send no-store as well. Five reads that used the bfcache-friendly max-age=0 go back to the default: the pages they serve are no-store already, so bfcache never applied, and the helper module goes with them. The routes that keep a weaker posture are listed with their reason in a guard (public files, the static category map, the deprecated flag route, the versioned avatar, the ETag-revalidated dose list and calendar feeds), and the guard fails on a new one or on a route handler outside apiHandler without the policy. The batch routes used no-store to keep a transient failure out of the idempotency cache. Now that every answer is no-store, that signal moves to an internal header (markNotReplayable) that withIdempotency reads and removes on every path. The service worker stores no API answer and the dashboard warm start keeps its data in its own IndexedDB store, so offline behaviour is unchanged. The size baselines grow by the lines the policy call and the marker take: apiHandler and the token route by one and two lines, the idempotency module by its marker.
…ason SECURITY.md and the security model diagram said Strict; the cookie has always been issued Lax. Lax is the right value: the OAuth return of an integration is a top-level navigation from another site that needs the session, and an OIDC sign-in reaches the app through a redirect chain that starts at the identity provider. Under Strict both would land signed out. Cross-site writes are refused separately by the Sec-Fetch-Site and Origin check. SECURITY.md also states that ending a user's sessions ends the native app's sign-ins and API tokens, and that API answers are not cached; the changelog records all three under Security.
…cache # Conflicts: # CHANGELOG.md # SECURITY.md # src/__tests__/baselines/version-stamp-comments.json
With API responses no-store, the browser no longer drains an unread body into its cache. The briefing read returned on a 422, 429, 503 or 403 without reading the body, so the request stayed open for the life of the page and held its connection; the tablet shell e2e waited for network idle on /insights and timed out.
…cache # Conflicts: # src/app/api/insights/targets/route.ts
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.
Three security fixes for the next patch.
Admin force logout ends every sign-in. The route deleted web sessions only, so the native app's refresh family and paired access token survived until the refresh window ran out. It now runs
destroyAllSessions, the same function as the password change and the admin password reset (moved tosrc/lib/auth/end-all-sessions.ts, re-exported from the session module).tests/integration/session-termination-paths.test.tsdrives force logout, admin reset, password change, admin deletion and self deletion through their routes and checks that the browser, the app's access and refresh tokens and an API token are refused and the device push credentials are gone; the force-logout case fails on the old route.session-termination-guard.test.tsholdssession.deleteManyto the listed places. Guardian revocation was checked: it clears the acting sessions and every guardian-minted link is re-checked against the live grant at serve time, so nothing changes there.Cache-Control: private, no-storeon every API answer. Set inapiHandlerwhen a route names no posture (plusPragma: no-cache), and applied by the OAuth routes and the MCP endpoint, which run outside the wrapper. The remaining weaker postures are listed with reasons inapi-cache-control-guard.test.ts(public files, static category map, deprecated flag route, versioned avatar, ETag-revalidated dose list and calendar feeds). The batch routes' "do not replay" signal for the idempotency layer wasno-store; it is now an internal header removed on every path. The service worker stores no API answer and the warm-start cache lives in its own IndexedDB store, so offline behaviour is unchanged.SECURITY.md said
SameSite=Strict; the cookie isLax, which is correct for the OAuth returns and the OIDC redirect chain. The doc and the security diagram now say so, with the reason.Gates run locally: typecheck, lint, prettier, full unit suite, full integration suite (one unrelated flake under load, green alone), OpenAPI regenerated.