Skip to content

feat: automated secret rotation policy for credentials (#281)#369

Open
omonxooo-commits wants to merge 1 commit intoEDOHWARES:mainfrom
omonxooo-commits:feature/281-secret-rotation
Open

feat: automated secret rotation policy for credentials (#281)#369
omonxooo-commits wants to merge 1 commit intoEDOHWARES:mainfrom
omonxooo-commits:feature/281-secret-rotation

Conversation

@omonxooo-commits
Copy link
Copy Markdown

Summary

Implements automated secret rotation for API keys and tokens, closing #281.

Changes

  • Model rotationPolicy.model.js — stores rotation interval, last/next rotation timestamps, and enabled flag per credential
  • Service rotation.service.jsrotateCredential re-encrypts tokens with AES-256-GCM; processDueRotations batch-processes all overdue policies
  • Controller rotation.controller.js — CRUD for policies, manual rotate endpoint, admin process-due endpoint
  • Routes credential.routes.js — registered at /api/credentials with OpenAPI JSDoc
  • Scheduler — hourly setInterval in server.js calls processDueRotations
  • Audit logging — every rotation writes an AuditLog entry (operation: UPDATE, resourceType: Credential); token values are never stored (redacted)
  • Tests — 6 unit tests in __tests__/rotation.test.js, all passing (node --test)
  • Docsdocs/secret-rotation.md covering API, data model, scheduler, and security notes

Acceptance Criteria

  • Rotation intervals defined per credential via RotationPolicy
  • Automated generation and replacement of secrets (AES-256-GCM, 256-bit entropy)
  • Audit log for every rotation event
  • Unit/integration tests added and passing
  • Documentation updated in /docs

- Add RotationPolicy model with intervalHours, nextRotationAt, enabled fields
- Add rotation.service: rotateCredential (AES-256-GCM re-encrypt) + processDueRotations
- Add rotation.controller + credential.routes (GET/POST/DELETE policy, POST rotate, POST rotate/process)
- Register /api/credentials in app.js
- Add hourly scheduler in server.js
- Audit log every rotation event (operation: UPDATE, resourceType: Credential)
- 6 unit tests passing (node --test)
- Docs: docs/secret-rotation.md
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@omonxooo-commits Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant