Enable managed auth in production - #39
Conversation
Flips VITE_MANAGED_AUTH to "true". Users sign in with Clerk and the server provisions a per-user OpenRouter key, so nobody pastes their own. Rollback is the same line back to "false" — one deploy, no data migration, since projects live in IndexedDB and are untouched either way. Also records the Phase 2 COEP spike result, open since June. Serving a real managed build behind the same COEP: require-corp / COOP: same-origin headers render.yaml sets and driving it in Chrome: crossOriginIsolated is true, Clerk's chunks load and initialize, ZERO external origins are requested, and nothing is blocked. The no-rhc + bundled @clerk/ui approach does what it was meant to. Two things must be true in the dashboards or this deploy is not what it looks like, and both are noted in render.yaml: VITE_CLERK_PUBLISHABLE_KEY must be set (unset silently falls back to BYOK, because isManagedAuthEnabled() requires BOTH), and Google must be enabled as a Clerk social connection — which on a production instance needs your own Google OAuth credentials. Still unvalidated: the OAuth redirect round-trip, and the managed agent loop itself. /api/agent/step and the three web tools have only ever seen fixtures. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019gS8yjMedGgujEad6zRD7i
hyperio-mc
left a comment
There was a problem hiding this comment.
Review
This is the managed-auth production flip — one config value from false to true, plus updated documentation. Exactly the separation PR #37 recommended.
What's good
Minimal and correct. 2 files, +28/-5. The actual code change is a single value in render.yaml ("false" -> "true"). The rest is documentation updates that record the COEP spike results, what's validated vs not, and the rollback procedure.
COEP spike is thorough. Served a real VITE_MANAGED_AUTH=true production build behind the same COEP/COOP headers, verified crossOriginIsolated=true (WebContainers still work), Clerk chunks load same-origin, zero external origins requested, nothing blocked. The no-rhc + bundled @clerk/ui approach is validated.
Rollback is trivial. Flip the value back to "false" — one deploy, no data migration. Projects live in IndexedDB and are untouched. This is the right risk profile for a production flip.
The comment update is excellent. It documents what must be true in the dashboards (VITE_CLERK_PUBLISHABLE_KEY set, Google enabled as Clerk social connection with your own OAuth credentials), and notes that unset publishable key silently falls back to BYOK because isManagedAuthEnabled() requires both. Future operators won't be confused by a silent fallback.
Honest about gaps. The PR body explicitly lists what this does NOT validate: the OAuth redirect round-trip (can't be tested with placeholder keys) and the managed agent loop (only seen fixtures). The first-run checklist is concrete and actionable.
oauthFlow: 'redirect' already handled. COOP: same-origin severs window.opener, so popup OAuth can't report back. This was handled before — the redirect flow is already forced. Good that it was checked.
CI: all green
3 checks pass — gleam+vitest+build (32s), server (41s), smoke browser (1m31s).
Verdict
This is the cleanest possible production flip — one config value, thorough validation behind it, trivial rollback, honest documentation of remaining gaps. The first-run checklist is the right post-merge plan.
Looks good to merge.
Reviewed by MC Agent
Flips
VITE_MANAGED_AUTHto"true". Users sign in with Clerk (Google) and the server provisions a per-user OpenRouter key, so nobody pastes their own.Rollback is the same line back to
"false"— one deploy, no data migration. Projects live in IndexedDB and are untouched either way.The Phase 2 COEP spike passes
Open since June, and the thing gating this whole rollout. I served a real
VITE_MANAGED_AUTH=trueproduction build behind the sameCOEP: require-corp/COOP: same-originheadersrender.yamlsets, and drove it in Chrome:crossOriginIsolatedtrue— WebContainers still workThe
no-rhc+ bundled@clerk/uiapproach does exactly what it was meant to. Managed mode also builds cleanly: ~240 code-split chunks, 4.4 MB total, none of it in the entry chunk.Worth noting the sign-in gate already forces
oauthFlow: 'redirect'—COOP: same-originseverswindow.opener, so popup OAuth could never report back and Google sign-in would hang. That was handled before I got here.What this does NOT validate
/api/agent/step,web_search,web_fetch, andweb_posthave only ever seen fixtures. Everything validated live so far went through BYOK.So this deploy is the first time that code serves a real request. Verified already: the API is deployed and healthy (
/api/health→ 200) and rejects unauthenticated calls cleanly (/api/me→ 401).First-run checklist after deploy
lazy-provisioning user …)web_searchneedsBRAVE_SEARCH_API_KEYor it reports itself unavailable (web_fetch/web_postare unaffected)web_postapproval — the one gated tool🤖 Generated with Claude Code
https://claude.ai/code/session_019gS8yjMedGgujEad6zRD7i