Skip to content

Add KeyManager for signing key lifecycle to authserver#3407

Merged
jhrozek merged 2 commits intomainfrom
auth-proxy-pr-11-key-management
Jan 23, 2026
Merged

Add KeyManager for signing key lifecycle to authserver#3407
jhrozek merged 2 commits intomainfrom
auth-proxy-pr-11-key-management

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Jan 22, 2026

This PR introduces signing key management for the OAuth authorization server, consisting of:

  • KeyStorage interface defining CRUD operations for signing key persistence. This enables is to add more key storage back ends in the future.
  • MemoryStorage implementation of KeyStorage supporting multiple keys for future rotation
  • KeyManager that handles key generation policy, algorithm selection, and RFC 7638 JWK Thumbprint derivation for deterministic key IDs.

When working on the original MVP of the authserver, having to generate signing keys manually was a complaint I received - production and hardened deployments would mount signing keys generated according to the organization requirements, but in order to just kick the tires in dev mode, it's been inconvenient.

Rather than requiring operators to pre-generate and configure keys, the KeyManager enables automatic key generation with secure defaults (ES256/P-256).

When no signing key is configured, the server generates an ephemeral key on startup—convenient for development while logging a warning about token invalidation on restart.

@jhrozek jhrozek requested a review from tgrunnagle January 22, 2026 14:01
@github-actions github-actions bot added the size/L Large PR: 600-999 lines changed label Jan 22, 2026
@jhrozek jhrozek force-pushed the auth-proxy-pr-11-key-management branch from 0419036 to c290a63 Compare January 22, 2026 14:07
@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 94.69027% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.98%. Comparing base (5429aa0) to head (690b981).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/authserver/server/keys/provider.go 94.49% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3407      +/-   ##
==========================================
+ Coverage   64.89%   64.98%   +0.09%     
==========================================
  Files         383      387       +4     
  Lines       37278    37437     +159     
==========================================
+ Hits        24191    24328     +137     
- Misses      11201    11224      +23     
+ Partials     1886     1885       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tgrunnagle
tgrunnagle previously approved these changes Jan 22, 2026
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 22, 2026
@jhrozek jhrozek force-pushed the auth-proxy-pr-11-key-management branch from 91fa576 to 2e90016 Compare January 22, 2026 20:53
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 22, 2026
tgrunnagle
tgrunnagle previously approved these changes Jan 23, 2026
jhrozek and others added 2 commits January 23, 2026 16:00
Introduces a KeyProvider interface with two implementations:
FileProvider loads a PEM key from disk (for production), and
GeneratingProvider creates an ephemeral key on first access (for
development). Configuration is via TOOLHIVE_AUTH_SIGNING_KEY_FILE
env var - when set, the key is loaded from that path; when unset,
an ephemeral key is generated.

At authserver startup, the server will call ConfigFromEnv() and
NewProviderFromConfig() to obtain a KeyProvider. In Kubernetes
deployments, the signing key is mounted from a Secret and the env
var points to the mounted path. The provider's SigningKey() method
returns the key for JWT signing, while PublicKeys() provides the
JWKS endpoint data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jhrozek jhrozek force-pushed the auth-proxy-pr-11-key-management branch from 2e90016 to 690b981 Compare January 23, 2026 17:30
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 23, 2026
@jhrozek jhrozek merged commit e7a9961 into main Jan 23, 2026
35 checks passed
@jhrozek jhrozek deleted the auth-proxy-pr-11-key-management branch January 23, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large PR: 600-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants