feat(connectors): secure credential vault + dashboard UI (#116)#117
Merged
Conversation
…t + dashboard UI (#116) Deliverables: - D1 migration 0023: connectors + connector_audit tables (write-only by design) - AES-GCM-256+HKDF per-connector crypto (CONNECTOR_MASTER_KEY env secret) - Service: addConnector / rotateConnector / revokeConnector / listConnectors / resolveConnector - Dashboard routes: GET+POST /admin/connectors, POST /:id/rotate, POST /:id/revoke - Telegram: allowed_chats JSON storage + isTelegramChatAllowed helper - 32 new tests (all AC covered); 843/843 pre-existing tests clean Security: - encrypted_secret never SELECT-ed outside resolveConnector() (grep-verified) - Write-only: list/rotate queries use explicit safe-column list (no encrypted_secret) - CONNECTOR_MASTER_KEY fail-closed: absent = no encrypt/decrypt, addConnector throws - isAdmin gate on all /admin/connectors routes (route layer, CSRF-covered) - Tenant-scoped: scope_id validated against this pot's D1 only Deploy prereq: `npx wrangler secret put CONNECTOR_MASTER_KEY` (openssl rand -hex 32) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
0023_connectors:connectorstable (AES-GCM ciphertext, never plaintext) +connector_auditappend-only logsrc/connectors/crypto.ts): AES-GCM-256 + HKDF-SHA256, per-connector salt (connector UUID), domain-separated info string per type. Fail-closed on bad/absent key.src/connectors/service.ts):addConnector/rotateConnector/revokeConnector/listConnectors/resolveConnector.encrypted_secretis SELECT-ed in exactly one place (resolveConnector); all other queries use explicit safe-column lists.src/dashboard/index.ts):GET /admin/connectors,POST /admin/connectors,POST /:id/rotate,POST /:id/revoke— allisAdmin-gated, CSRF-covered, tenant-scoped.allowed_chatsstored as JSON inmeta;telegramAllowedChats()+isTelegramChatAllowed()helpers.Encryption key situation
CONNECTOR_MASTER_KEYis a deploy prerequisite — not inwrangler.toml.Fail-closed: absent key =
addConnector()throws,resolveConnector()returns null.Write-only invariant — GREP VERIFIED
encrypted_secretappears insrc/connectors/service.tsonly in:addConnector)rotateConnector)resolveConnectorONLY — the single decrypt pathlistConnectors()androtateConnector()load queries use explicit safe-column lists with noencrypted_secret. Verified by testwrite-only SQL invariant.Test plan
npm run typecheck— clean🤖 Generated with Claude Code