Skip to content

[Feature]: Add Managed JWT Signing Key Rotation #173

Description

@mckaragoz

Summary

Introduce first-class JWT signing key rotation support in UltimateAuth while preserving the existing IJwtSigningKeyProvider and IJwtVerificationKeyProvider extension points.

The current built-in implementation supports a single configured HS256 signing key. Although custom providers can supply multiple trusted verification keys, UltimateAuth does not yet provide a managed rotation lifecycle.

Motivation

Replacing the configured JWT signing key currently invalidates previously issued JWTs unless applications supply custom verification key management.

A managed rotation mechanism should allow applications to transition between signing keys without unnecessarily interrupting active authentication.

Proposed Scope

Key management

  • Support multiple configured JWT signing keys with unique key IDs (kid).
  • Designate exactly one active signing key for new tokens.
  • Allow previous keys to remain available for verification.
  • Support key states such as active, verification-only, and retired.
  • Reject duplicate key IDs, invalid key material, and unsupported algorithms.

Rotation lifecycle

  • Introduce a new signing key without immediately removing the previous key.
  • Switch new token issuance to the new active key.
  • Continue validating existing tokens against trusted verification-only keys.
  • Retire previous keys after their issued tokens have expired, accounting for clock skew.
  • Support emergency key revocation when a key is compromised.

Provider integration

  • Preserve compatibility with IJwtSigningKeyProvider.
  • Preserve compatibility with IJwtVerificationKeyProvider.
  • Maintain strict kid matching.
  • Never accept signing keys, algorithms, or key URLs supplied by untrusted tokens.
  • Keep rotation independent of authentication modes and session persistence.

Configuration and security

  • Continue rejecting public development keys outside Development.
  • Document secure key storage and deployment practices.
  • Ensure key material is never exposed through diagnostics or logs.
  • Avoid introducing automatic rotation that depends on persistent storage or external infrastructure by default.

Acceptance Criteria

  • New JWTs use the configured active signing key and its kid.
  • JWTs signed by verification-only keys remain valid until their normal expiration.
  • Retired or revoked keys are rejected.
  • Unknown or duplicate key IDs are rejected.
  • Key rotation does not disable issuer, audience, lifetime, tenant, or algorithm validation.
  • Rotation behavior is covered by unit and integration tests.
  • Existing single-key configurations remain compatible.
  • Documentation includes an example of performing a safe rotation.

Non-Goals

  • Mandatory external KMS integration.
  • Automatic scheduled rotation.
  • Dynamic retrieval of signing keys from untrusted token metadata.
  • Changing token formats or authentication-mode semantics.
  • Requiring database persistence for basic JWT validation.

Activity

  1. added this to the v0.3.0 milestone on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions