ToolypetMCP
intermediate3 minutescross hub

API Key Rotation Workflow

Generate new API keys, create HMAC signatures for validation, and hash old keys for audit logging.

api-keyrotationhmacsecurity

Wann dieses Rezept verwenden

Structured API key rotation with audit trail. Ensures new keys work before decommissioning old ones, and maintains security logs without storing raw secrets.

Schritte

1

Generate new API key

Eingabeaufforderung:Generate a new 512-bit API key in base64 format for rotation
2

Validate new key with HMAC

Eingabeaufforderung:Create HMAC-SHA256 signature of a test payload using the new key to verify it works
3

Hash old key for audit trail

Eingabeaufforderung:SHA-256 hash the old API key for audit log storage (never store raw keys in logs)
4

Create audit event ID

Eingabeaufforderung:Generate a UUID v4 as the rotation event ID for tracking

Häufig gestellte Fragen

How often should API keys be rotated?

Every 90 days for production keys, immediately on team member departure, and instantly if a key is potentially compromised.

Why hash old keys for audit logs?

You need to identify which key was used without storing the actual secret. A SHA-256 hash lets you match against known keys without exposure risk.

Verwandte Rezepte