Skip to content

feat(api): record which key a request used, masked - #93

Merged
fylorn merged 1 commit into
mainfrom
feat/request-key-masked
Sep 22, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/request-key-masked

Conversation

@fylorn

@fylorn fylorn commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Every request record and security log entry now carries the gateway key it used, masked the way the keys page shows it (tw-re…wb4e), so the desktop app can write "tw-re…wb4e (claude-code)" instead of the key's name alone.

Why record it

The name alone does not say which key: names are free text and change, and a key can be rotated under the same name. Looking the mask up by name when the page is drawn would put the current key's tail on requests made with the old one. For a security log that is the wrong answer, so the mask is taken when the request arrives and stored with it.

What changes

  • key_masked on RequestStarted and LocallyAnswered, taken from the matched client entry's key with tw_secret::mask_secret.
  • requests.key_masked (schema 16), out through HistoryRow and SecurityEventView.
  • The gateway passes the source address and the masked key down together as one Sender, rather than adding another argument to the pipeline.

Additive; CONTROL_API_VERSION unchanged.

Tests

  • A request through the gateway starts with key_masked tw-re…wb4e and no peer, since it came from this machine. The toolwall tests now use a key of realistic length; a ten-character one masks to all dots.
  • The store round-trips the mask; the migration test drops the new column in its simulated old database.
  • The security log returns the mask with the entry.
  • cargo test --workspace (1512 passed), clippy -D warnings, fmt.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit c1f122e into main Sep 22, 2026
1 check passed
@fylorn
fylorn deleted the feat/request-key-masked branch September 22, 2026 03:19
@fylorn fylorn mentioned this pull request Sep 22, 2026
fylorn added a commit that referenced this pull request Sep 22, 2026
Requests record which key they used, masked (#93). Additive;
CONTROL_API_VERSION unchanged.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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