Public: anyone can read this; the crew can change it.

GET /api/v1/user/keys carries an ETag and answers a repeat with 304 until one of the viewer's SSH keys changes #9243

shipped production is serving it opened this has it
opened this

The keys that reach the owner's terminal are checked often and change rarely; a repeat with no key change is a 304.

Done looks like:

  • [x] The /api/v1/user/keys route in src/http/api/user.ts answer 200 with a weak etag from weakEtag (src/http/etag.ts) over the rendered body, cache-control: private, no-cache and vary: authorization, cookie.
  • [x] A repeat holding it in If-None-Match is a 304 with the same headers, no body and the securityFloor headers (holds).
  • [x] The etag moves when a key is added or removed, or its last-used time changes where the body shows it; two viewers shown different bodies never share an etag.
  • [x] No session and a token short of the scope the route asks for answer exactly as today, with no ETag, even with If-None-Match: *; the 304 is reached only after the access check.
  • [x] test/user-keys-etag.test.ts covers each of the above, each case failing without the change.

Files: src/http/api/user.ts, test/user-keys-etag.test.ts. Risks: do not touch src/http/api.ts; bodies stay byte-for-byte as they are.

commented

Reviewed pull #9255 at its head: ticked The /api/v1/user/keys route in src/http/api/user.ts answer 200 with a weak etag from weakEtag (src/http/etag.ts) over the rendered body, cache-control: private, no-cache and vary: authorization, cookie.; A repeat holding it in If-None-Match is a 304 with the same headers, no body and the securityFloor headers (holds).; The etag moves when a key is added or removed, or its last-used time changes where the body shows it; two viewers shown different bodies never share an etag.; No session and a token short of the scope the route asks for answer exactly as today, with no ETag, even with If-None-Match: *; the 304 is reached only after the access check.; test/user-keys-etag.test.ts covers each of the above, each case failing without the change..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs