Repository navigation
feat: API key rotation and revocation (#40) - #142
Merged
victorisiguzoruzoma874 merged 1 commit intoOct 19, 2026
Merged
victorisiguzoruzoma874 merged 1 commit into
victorisiguzoruzoma874 merged 1 commit into
Conversation
Add POST /publishers/me/api-keys/rotate that issues a new key and immediately invalidates the old one. Changes: - drizzle/0012_api_key_rotation.sql: add api_key_revoked_at column - src/db/schema.ts: add apiKeyRevokedAt nullable timestamp field - src/middleware/apiKeyAuth.ts: reject keys where apiKeyRevokedAt IS NOT NULL - src/services/publisherService.ts: rotateApiKey() — atomic hash swap - src/routes/publishers.ts: POST /publishers/me/api-keys/rotate route - src/routes/publishers.api-key-rotation.test.ts: 9 new tests - src/routes/publishers.test.ts: fix authedPublisher fixture (add apiKeyRevokedAt: null) Acceptance criteria met: - Old key returns 401 after rotation (hash replaced in DB) - New key works immediately (200) - Tests cover both cases plus explicit revocation via apiKeyRevokedAt
|
@wendyamoni-creator 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! 🚀 |
|
@wendyamoni-creator is attempting to deploy a commit to the work Team on Vercel. A member of the Team first needs to authorize it. |
victorisiguzoruzoma874
merged commit Oct 19, 2026
366828d
into
SynapsVault:main
0 of 2 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #40.
Publishers can now rotate their API key via
POST /publishers/me/api-keys/rotate. The old key is invalidated immediately; the new plaintext key is returned once in the response.Changes
drizzle/0012_api_key_rotation.sqlapi_key_revoked_atcolumn topublisherssrc/db/schema.tsapiKeyRevokedAtnullable timestamp fieldsrc/middleware/apiKeyAuth.tsapiKeyRevokedAt IS NOT NULLsrc/services/publisherService.tsrotateApiKey()— single atomic UPDATE that swaps the hashsrc/routes/publishers.tsPOST /publishers/me/api-keys/rotateroutesrc/routes/publishers.api-key-rotation.test.tssrc/routes/publishers.test.tsauthedPublisherfixture — addapiKeyRevokedAt: nullHow it works
rotateApiKey()does one atomicUPDATE— setsapiKeyHashto the new hash and setsapiKeyRevokedAt = null. The old key's hash is overwritten so it matches nothing on the next lookup.apiKeyRevokedAtto a timestamp without changing the hash.apiKeyAuthrejects any key whose row has a non-nullapiKeyRevokedAt, even if the hash still matches.Acceptance criteria
401after rotation200)Tested