sec(api): Cache-Control: no-store on /auth/me#191
Merged
Conversation
AUTH-146: /auth/me returns the caller's session-bound identity
(user_id, team_id, email, tier, experiments-bucket, admin flags,
impersonation state). None of those values are safe to cache — a
service worker, browser back-cache after logout, or an intermediate
proxy that respects the default heuristic-cache rules could re-serve
them to a subsequent session (different user on the same machine,
post-rotation token, post-impersonation drop).
`Cache-Control: no-store` is the unconditional opt-out (RFC 9111
§5.2.2.5: "no part of either the immediate request or response is
stored by any cache"). Paired with the existing 24h-clamped JWT and
jti-revocation on logout, this closes the per-machine
stale-identity vector.
Coverage block (rule 17):
Symptom: /auth/me emits no Cache-Control hint
Enumeration: rg -n 'cliAuthH\.GetCurrentUser\|"/auth/me"' internal/
Sites found: 1 production handler (cli_auth.go:211)
Sites touched: 1 — c.Set("Cache-Control", "no-store") before c.JSON
Coverage test: TestAuthMe_CacheControlNoStore exercises the production
wiring (RequireAuth + real JWT) so the no-store header
is asserted in the real 200 path; tokens-tolerant
(matches "no-store" as a directive in a comma-list)
so a forward-compat directive list "no-store, no-cache,
private" stays green.
Live verified: pending CI auto-deploy (rule 14 SHA check after merge).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
792af01 to
3a6fa69
Compare
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.
Summary
Cache-Control: no-store, a service worker / browser back-cache / intermediate proxy could re-serve those values to a subsequent session — different user on the same machine, post-rotation token, post-impersonation drop.Cache-Control: no-store(RFC 9111 §5.2.2.5 — the only directive that forbids storing the response at all) before the JSON return.Coverage block (rule 17)
Test plan
go build ./...cleango vet ./...cleango test ./internal/handlers -run TestAuthMeall pass (existing + new)curl -i -H "Authorization: Bearer <pat>" https://api.instanode.dev/auth/me | grep -i 'cache-control'Inbox: AUTH-146