Skip to content

sec(api): Cache-Control: no-store on /auth/me#191

Merged
mastermanas805 merged 1 commit into
masterfrom
fix/api-auth-me-no-store-cache-2026-05-30
May 30, 2026
Merged

sec(api): Cache-Control: no-store on /auth/me#191
mastermanas805 merged 1 commit into
masterfrom
fix/api-auth-me-no-store-cache-2026-05-30

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Summary

  • AUTH-146: /auth/me returns the caller's session-bound identity (user_id, team_id, email, tier, experiments-bucket, admin flags, impersonation state). Without 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.
  • Stamp 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)

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).

Test plan

  • go build ./... clean
  • go vet ./... clean
  • go test ./internal/handlers -run TestAuthMe all pass (existing + new)
  • Live verify after merge: curl -i -H "Authorization: Bearer <pat>" https://api.instanode.dev/auth/me | grep -i 'cache-control'

Inbox: AUTH-146

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>
@mastermanas805 mastermanas805 force-pushed the fix/api-auth-me-no-store-cache-2026-05-30 branch from 792af01 to 3a6fa69 Compare May 30, 2026 08:02
@mastermanas805 mastermanas805 merged commit eedce75 into master May 30, 2026
14 checks passed
@mastermanas805 mastermanas805 deleted the fix/api-auth-me-no-store-cache-2026-05-30 branch May 30, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant