Skip to content

feat(git): Add key_id to name a git grant key by its kid - #173

Merged
vaind merged 1 commit into
mainfrom
ivan/git-grant-key-id
Nov 3, 2026
Merged

vaind merged 1 commit into
mainfrom
ivan/git-grant-key-id

Conversation

@vaind

@vaind vaind commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Seer reads a grant's kid with jwt.get_unverified_header just to log which key signed it (getsentry/seer#9252). This adds key_id(public_key: str) -> str, which returns the kid for an Ed25519 public key in PEM and raises GitGrantKeyError for a bad key, as verify_grant does. A signer calls key_id(public_key_of(private_key)), so there's no separate private-key form.

Not included: reporting which key verified a grant. It would need a second verify function or a new tag on every GitServer metric, and the rotation doesn't need it, since no grant signed with the old key is still valid 15 minutes after Seer switches.

Tests check key_id against the kid header from sign_grant, and check that bad keys raise without quoting the key.

Changelog Entry

  • Add key_id to get a git grant key's kid from its public key, so callers needn't parse the grant's JWT header

🤖 Generated with Claude Code

Consumers that log which key signed a grant, like Seer during a key
rotation, had to parse the JWT header with PyJWT to read the kid. The
kid is derived from the key, so the library can hand it out directly
and keep the derivation in one place.

A signer gets its own id with key_id(public_key_of(private_key)) rather
than a second, private-key form: the composition is one line and keeps
the API to one function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vaind
vaind marked this pull request as ready for review November 3, 2026 18:36
@vaind
vaind requested a review from a team as a code owner November 3, 2026 18:36
@vaind
vaind merged commit 192fccb into main Nov 3, 2026
14 checks passed
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.

2 participants