Skip to content

🔑 API Key Expiry & Rotation Mechanism #55

@mijinummi

Description

@mijinummi

📌 Overview

Long-lived API keys pose a significant security risk if compromised. To improve security and compliance, GasGuard requires API key expiry and rotation mechanisms.

This task introduces time-bound API keys with rotation endpoints, ensuring secure and manageable access for developers and integrators.


🎯 Objective

Build a secure API key management system that:

  • Supports automatic key expiry
  • Enables seamless key rotation
  • Maintains backward compatibility with active sessions
  • Enhances security compliance and reduces risk of key compromise

🛠 Scope of Work

1️⃣ API Key Expiry

  • Assign expiration timestamp to each API key at creation
  • Support configurable expiry periods (e.g., 30 days, 90 days)
  • Automatically revoke expired keys
  • Return clear error response for expired keys:
{
  "error": "APIKeyExpired",
  "message": "This API key has expired. Please rotate or request a new key."
}


---
## 2️⃣ Key Rotation Endpoint

Expose endpoints to rotate API keys securely:

POST /api-keys/:key/rotate
GET  /api-keys/:key/status

---
##3️⃣ Integration & Enforcement
Validate API keys on every request
Reject expired or revoked keys
Maintain audit logs for key rotations and expirations
Optional: alert developers prior to key expiry


---
## ✅ Acceptance Criteria

1. API keys expire correctly according to configuration
2. Rotation endpoint generates new keys and invalidates old keys
3. Expired or revoked keys rejected with proper error
4. Audit logs maintained for key events
5. Documentation updated
6. All tests passing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Nest.jsStellar WaveIssues in the Stellar wave programbackendNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions