Skip to content

(feat/partner-integrations) Rotate endpoint#2547

Merged
nickscamara merged 2 commits intomainfrom
nsc/rotate-api-key
Dec 12, 2025
Merged

(feat/partner-integrations) Rotate endpoint#2547
nickscamara merged 2 commits intomainfrom
nsc/rotate-api-key

Conversation

@nickscamara
Copy link
Copy Markdown
Member

@nickscamara nickscamara commented Dec 12, 2025

Summary by cubic

Adds a secure endpoint for partner integrations to rotate a leaked API key. It deletes the old key and returns a new key for the same team and owner.

  • New Features
    • POST /admin/integration/rotate-api-key
    • Auth via Bearer token; SHA-256 hash matched to integration key
    • Validates apiKey input and ensures the team belongs to the integration
    • Deletes the provided key and creates a new “Default” key
    • Responds with { apiKey } in FC format; returns 400/401/404/500 on errors

Written for commit 1c49a8c. Summary will update automatically on new commits.

@nickscamara nickscamara requested a review from mogery December 12, 2025 15:21
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/api/src/controllers/v0/admin/rotate-api-key.ts">

<violation number="1" location="apps/api/src/controllers/v0/admin/rotate-api-key.ts:101">
P1: Non-atomic delete/insert creates data loss risk. If the insert fails after the delete succeeds, the user permanently loses their API key. Consider creating the new key first, then deleting the old one on success, or implementing a soft-delete/recovery mechanism.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Comment thread apps/api/src/controllers/v0/admin/rotate-api-key.ts Outdated
@nickscamara
Copy link
Copy Markdown
Member Author

@cubic re-run

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented Dec 12, 2025

@cubic re-run

@nickscamara I've started the AI code review. It'll take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/api/src/controllers/v0/admin/rotate-api-key.ts">

<violation number="1" location="apps/api/src/controllers/v0/admin/rotate-api-key.ts:120">
P1: Security issue: When delete fails for a leaked API key, the endpoint still returns success. The caller will believe the leaked key was revoked when it remains active. Consider returning an error response or at least including a warning in the response body when the old key couldn&#39;t be deleted.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Comment thread apps/api/src/controllers/v0/admin/rotate-api-key.ts
@nickscamara nickscamara merged commit da63c76 into main Dec 12, 2025
12 checks passed
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.

2 participants