feat(web): store per-user Daytona/OpenAI keys in WorkOS Vault#17
Draft
MohtashamMurshid wants to merge 1 commit into
Draft
feat(web): store per-user Daytona/OpenAI keys in WorkOS Vault#17MohtashamMurshid wants to merge 1 commit into
MohtashamMurshid wants to merge 1 commit into
Conversation
Resolve dashboard run credentials in priority order: request body (BYOK) > signed-in user's WorkOS Vault secrets > DAYTONA_API_KEY/OPENAI_API_KEY env vars (local dev). Add AuthKit sign-in (proxy, /login, /callback, AuthKitProvider) and a /dashboard/settings page where each user stores their keys encrypted in WorkOS Vault, scoped to their user id. Degrades gracefully to local mode (no auth, env/BYOK only) when WorkOS is not configured, so local development is unchanged. Co-authored-by: Mohtasham Murshid <MohtashamMurshid@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Builds on the live
/dashboard(PR #16). The dashboard previously required users to paste their Daytona + OpenAI keys (or remember them inlocalStorage) on every run. This adds per-user, server-side key storage backed by WorkOS AuthKit + Vault, while keeping env vars working for local development.DAYTONA_API_KEY/OPENAI_API_KEYenv vars (local dev).proxy.ts,/login,/callback,AuthKitProvider) and a/dashboard/settingspage where each user stores their keys, encrypted in WorkOS Vault and scoped to their user id.Base: this PR is stacked on
cursor/dashboard-ui-ba70.Surface(s) affected
apps/web)Breaking changes?
How credentials resolve
Each key resolves independently (a user can keep one in Vault and override the other for a single run):
/dashboard/settings, decrypted only server-sideDAYTONA_API_KEY/OPENAI_API_KEY— local-dev fallbackWhen
WORKOS_API_KEY/WORKOS_CLIENT_ID/WORKOS_COOKIE_PASSWORDare unset, the app stays in local mode: the proxy is a pass-through, sign-in/settings show a "local mode" notice, and the BYOK form + env vars still work.Screenshots / output samples
Dashboard in local mode — keys detected from environment variables, fields become optional overrides:
Dashboard local keys banner
Settings page in local mode — explains the WorkOS config needed to enable account-based Vault storage:
Settings local mode notice
Walkthrough:
dashboard_localmode_and_settings_walkthrough.mp4
Files
app/_lib/workos.ts— WorkOS config detection (isWorkOSConfigured).app/_lib/auth.ts—getCurrentUser()(guardedwithAuth).app/_lib/credentials.ts— WorkOS Vault per-user secret read/save/clear + masked status.app/_lib/credentials-resolver.ts(+.test.ts) — pure body→vault→env priority resolver, unit tested.app/api/design/route.ts— resolves run credentials via the chain; keys now optional.app/dashboard/settings/*— settings page, server actions, client form.proxy.ts,app/callback/route.ts,app/login/route.ts,app/layout.tsx— AuthKit wiring (all gated on config).app/dashboard/page.tsx,_components/dashboard-runner.tsx,_components/types.ts— auth/credentials banner + optional form keys.apps/web/README.md— documents the env vars and credential model.Verification
bun run typecheck(apps/web) — passesbun run build(apps/web) — passes;/callback,/login,/dashboard/settingsand Proxy show in the route tablebun test app/_lib/credentials-resolver.test.ts— 6/6 passPOST /api/designreturns400 missing_credentialswith no keys/env; resolves and runs the SDK when keys come from the body or from env varsChecklist
bun run lintpassesbun run typecheckpassesCHANGELOG.mdupdated under## [Unreleased]Note: the WorkOS Vault path itself (signed-in storage) could not be exercised end-to-end here because no WorkOS account/credentials are available in this environment; the resolver, env-var fallback, and local-mode UI are tested above.
To show artifacts inline, enable in settings.