Skip to content

Support multiple signing keys in JWKS for key rotation #65

@eswan18

Description

@eswan18

Problem

The JWKS endpoint (`/.well-known/jwks.json`) only serves a single key with a hardcoded key ID (`"key-1"`). To rotate the signing key, the operator must deploy a new key and wait for all existing tokens (up to 1 hour for access tokens, 30 days for refresh tokens) to expire before removing the old key — or accept that outstanding tokens will fail validation.

Why it matters

  • Key rotation is a security best practice (limits blast radius of a compromised key)
  • Compliance frameworks often require periodic key rotation
  • Without multi-key JWKS, rotation requires coordinated downtime or causes token validation failures for clients that cache the old JWKS

Suggested approach

  1. Support loading multiple signing keys (current + previous) from configuration
  2. Sign new tokens with the current key (identified by `kid`)
  3. Serve all active public keys in the JWKS endpoint
  4. `ValidateToken` should select the correct public key based on the JWT's `kid` header
  5. After all tokens signed with the old key have expired, remove it from the config

This is low priority for a personal project but would be a nice infrastructure improvement if the identity provider is ever used more broadly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions