Skip to content

feat: Add encrypted Groq BYOK credential storage and resolution#418

Open
NirmalSingh-09 wants to merge 1 commit into
MRIARC-08:mainfrom
NirmalSingh-09:feat/encrypted-groq-byok-issue-368
Open

feat: Add encrypted Groq BYOK credential storage and resolution#418
NirmalSingh-09 wants to merge 1 commit into
MRIARC-08:mainfrom
NirmalSingh-09:feat/encrypted-groq-byok-issue-368

Conversation

@NirmalSingh-09

Copy link
Copy Markdown
Contributor

Closes #368
What this PR does
Implements encrypted Groq BYOK (Bring Your Own Key) credential storage so user API keys are never persisted in plaintext.
Changes

src/prisma/schema.prisma — adds ProviderCredential model with ciphertext, keyVersion, maskedSuffix, revocation state
src/lib/crypto.ts — AES-256-GCM envelope encryption (random data key per credential, encrypted with master key)
src/lib/env.ts — adds CREDENTIAL_MASTER_KEY validation
src/modules/credentials/ — service, controller, types, index
src/app/api/credentials/ — POST /api/credentials, GET /api/credentials, DELETE /api/credentials/:id
src/lib/crypto.test.ts — 6 passing tests verifying encrypt/decrypt, no plaintext leakage, random IVs

Security guarantees

Plaintext keys are never persisted — only ciphertext stored in DB
API responses expose only masked suffix (last 4 chars)
resolveForInternalUse is server-side only — never called from client or queues
Migration note: requires CREDENTIAL_MASTER_KEY (min 32 chars) in .env

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

@NirmalSingh-09 is attempting to deploy a commit to the Adarsh's projects Team on Vercel.

A member of the Team first needs to authorize it.

@MRIARC-08 MRIARC-08 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@NirmalSingh-09 I can’t review or merge this one yet because it now conflicts with current main in src/prisma/schema.prisma.

Main has picked up new Prisma schema changes from recently merged PRs, so please rebase this branch on the latest main, resolve the schema conflict, regenerate Prisma/lockfile output only if needed, and push the result.

After that I’ll recheck the credential encryption and response-sanitization behavior.

@MRIARC-08 MRIARC-08 added gssoc gssoc level:advanced GSSoC difficulty: advanced type:security Security related contribution area:ai-backend Python AI service, embeddings, retrieval, and LLM infrastructure labels Jun 25, 2026
@NirmalSingh-09 NirmalSingh-09 force-pushed the feat/encrypted-groq-byok-issue-368 branch from 0b8429f to 8ede656 Compare June 26, 2026 18:45
@NirmalSingh-09

Copy link
Copy Markdown
Contributor Author

@MRIARC-08 Rebased onto latest upstream main and resolved the schema.prisma conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai-backend Python AI service, embeddings, retrieval, and LLM infrastructure gssoc gssoc level:advanced GSSoC difficulty: advanced type:security Security related contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SECURITY][AI BACKEND] Add encrypted Groq BYOK credential storage and resolution

2 participants