Skip to content

feat: Key-Rotate command - #205

Merged
alex289 merged 7 commits into
mainfrom
feature/key_rotate_command
Jun 20, 2026
Merged

feat: Key-Rotate command#205
alex289 merged 7 commits into
mainfrom
feature/key_rotate_command

Conversation

@alex289

@alex289 alex289 commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Add a new hub key rotate command to re-encrypt database fields from an old APP_SECRET to the current one.
  • Cover agents, applications, repositories, notifications, and OIDC providers, with confirmation prompts and safe validation for secret length and equality.
  • Surface a concise success summary after rotation and block execution in demo mode or when the database is unavailable.
  • Add tests for rotation behavior, secret validation, and command wiring.

Testing

  • Added unit tests covering successful re-encryption, invalid secret rejection, and CLI command registration.
  • Not run (not requested).

Fixes #167

@alex289 alex289 self-assigned this Jun 19, 2026
@alex289 alex289 added enhancement New feature or request and removed backend hub labels Jun 19, 2026
@alex289
alex289 marked this pull request as ready for review June 19, 2026 09:06
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.57895% with 49 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/cmd/hub/key_rotate.go 83.75% 21 Missing and 18 partials ⚠️
backend/internal/hub/crypto/crypto.go 65.00% 4 Missing and 3 partials ⚠️
backend/cmd/hub/main.go 50.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Hub CLI surface for rotating the database encryption key (derived from APP_SECRET) by re-encrypting all encrypted DB fields using a provided previous secret, with confirmation prompts, demo-mode blocking, and unit tests to validate rotation behavior.

Changes:

  • Register a new hub key command group with a rotate subcommand.
  • Implement key rotation logic to re-encrypt encrypted fields across Agents, Applications, Repositories, Notifications, and OIDC providers within a DB transaction.
  • Add unit tests covering successful re-encryption, invalid secret validation, and command wiring.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
backend/cmd/hub/main.go Registers the new key command with the Hub CLI root command.
backend/cmd/hub/key_rotate.go Implements hub key rotate, including secret validation, confirmation flow, DB connection, transactional re-encryption, and result rendering.
backend/cmd/hub/key_rotate_test.go Adds tests for rotation correctness and secret validation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/cmd/hub/key_rotate.go
Comment thread backend/cmd/hub/key_rotate.go Outdated
Comment thread backend/cmd/hub/key_rotate.go Outdated
Comment thread backend/cmd/hub/key_rotate.go Outdated

@timokoessler timokoessler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool

Comment thread backend/cmd/hub/key_rotate.go Outdated
Comment thread backend/cmd/hub/key_rotate.go
Comment thread backend/cmd/hub/key_rotate.go Outdated
Comment thread backend/cmd/hub/key_rotate.go Outdated
Comment thread backend/cmd/hub/key_rotate.go Outdated
@alex289
alex289 enabled auto-merge (squash) June 20, 2026 10:32
@alex289
alex289 merged commit 309b975 into main Jun 20, 2026
11 checks passed
@alex289
alex289 deleted the feature/key_rotate_command branch June 20, 2026 14:34
@orcacd-bot orcacd-bot Bot mentioned this pull request Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend enhancement New feature or request hub

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Key rotate command

3 participants