Skip to content

(feat/partner-integrations) Rotate endpoint - #2547

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

nickscamara merged 2 commits into
mainfrom
nsc/rotate-api-key

Conversation

@nickscamara

@nickscamara nickscamara commented Dec 12, 2025

Copy link
Copy Markdown
Member

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

@cubic-dev-ai cubic-dev-ai Bot 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.

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

cubic-dev-ai Bot commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

@cubic re-run

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

@cubic-dev-ai cubic-dev-ai Bot 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.

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
jerbao pushed a commit to jerbao/firecrawl-custom that referenced this pull request Aug 22, 2026
* Nick: rotate partner integration keys

* Update rotate-api-key.ts
zeekay pushed a commit to Dream-AI-4444/firecrawl that referenced this pull request Sep 10, 2026
* Nick: rotate partner integration keys

* Update rotate-api-key.ts
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