Skip to content

feat: ephemeral one-shot keys (Story 2.5)#131

Merged
farovictor merged 1 commit intomainfrom
feat/one-shot-keys
Apr 5, 2026
Merged

feat: ephemeral one-shot keys (Story 2.5)#131
farovictor merged 1 commit intomainfrom
feat/one-shot-keys

Conversation

@farovictor
Copy link
Copy Markdown
Owner

Summary

  • Adds one_shot: true support to POST /v1/keys and the request_key MCP tool
  • One-shot keys are marked used: true before the upstream request is forwarded — prevents replay even if the upstream returns an error
  • Second use returns 401 {"error":"key already used"}
  • one_shot and used fields are visible in GET /v1/keys
  • Unused one-shot keys expire normally at expires_at
  • Adds source, one_shot, used columns via migrations 007 + 008

Test plan

  • TestOneShotKeyUsedOnce — first request 200, second 401 "key already used"
  • TestOneShotKeyAppearsInListone_shot: true visible in list
  • TestRegularKeyNotAffectedByOneShotLogic — regular key usable 3× without issue
  • TestMCPRequestKeyOneShot — MCP-issued key has one_shot: true
  • Full suite green

🤖 Generated with Claude Code

- Add OneShot + Used fields to VirtualKey model + migration 008
- Proxy rejects one-shot keys with 401 "key already used" after first use
- Key is marked used before forwarding to prevent replay on upstream error
- POST /v1/keys accepts one_shot: true (pass-through via struct decode)
- MCP request_key tool accepts one_shot: true argument
- one_shot and used fields appear in GET /v1/keys list
- 4 new tests: used-once enforcement, list visibility, regular key unaffected,
  MCP one-shot flag propagation
- Regenerate swagger spec

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@farovictor farovictor self-assigned this Apr 5, 2026
@farovictor farovictor merged commit 1b851a4 into main Apr 5, 2026
8 checks passed
@farovictor farovictor deleted the feat/one-shot-keys branch April 5, 2026 21:57
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