Repository navigation
build(deploy): mark the sign-in widget's /api/v1 flow writes for BotID, and check them in production - #2625
build(deploy): mark the sign-in widget's /api/v1 flow writes for BotID, and check them in production#2625fforootd wants to merge 1 commit into
Conversation
…D, and check them in production Since the widget calls the API under /api/v1 (#2359), BotID's client protected /cloud/zitadel/flow while the widget sent /cloud/zitadel/api/v1/flow. The functions' check read the unmarked write as a bot, so every sign-in and sign-up on a preview answered 403 auth.bot_suspected. The protected paths now come from the contract, built with the base URL the widget's API client uses. Production's add-on now starts BotID's client and sends the widget through the functions too (root ADR 084 §5, §9 step 2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
| // never marks is refused for every person. | ||
| it.each(FLOW_WRITES)("checks $method $path, which BotID's client marks", ({ method, path }) => { | ||
| expect(path.startsWith(`${SIGN_IN_PREFIX}/`)).toBe(true); | ||
| const sent = path.slice(SIGN_IN_PREFIX.length).replace("*", "flw_1"); |
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🔵 Needs a closer look
This change introduces production BotID enforcement in critical authentication flows, where false positives could block real users, so a human-reviewed rollout plan with monitoring and failure-mode handling is needed before merging.
No open issues 🎉
What changed in this PR
This pull request aligns the hosted cloud console’s sign-in/sign-up widget routing with BotID-protected /api/v1 flow writes (preventing false auth.bot_suspected 403s), centralizes the relevant path contract to avoid drift, and enables the same BotID-backed routing behavior in production (not only previews), with corresponding ADR/runbook updates.
Changes:
- Centralizes
SIGN_IN_PREFIXandFLOW_WRITESin@zitadel/cloud-functions/contractusingapiBaseUrl()to keep BotID marking in sync with the widget client. - Updates cloud-functions sign-in forwarding and adds tests to ensure BotID-marked paths match
isFlowWrite()checks. - Updates the cloud console add-on to start the BotID client in production and route widget traffic consistently via
/cloud/zitadel, plus documentation updates.
Review notes (nit):
apps/cloud-functions/src/contract.ts: Header comment claims everything is beneath/cloud/api/, but this contract also defines/cloud/zitadelpaths (SIGN_IN_PREFIX/FLOW_WRITES), making the comment misleading.
| File | Summary |
|---|---|
docs/runbooks/cloud.md |
Updates the cloud runbook to reflect BotID-enabled routing behavior beyond previews. |
docs/adrs/084-hosted-cloud-business-systems.md |
Updates ADR 084 wording/rollout notes to reflect production behavior for the sign-in hop and BotID. |
apps/cloud-functions/src/sign-in.ts |
Switches to importing SIGN_IN_PREFIX from the shared contract while keeping forwarding/flow-write logic. |
apps/cloud-functions/src/sign-in.spec.ts |
Adds a contract-based test asserting BotID-marked paths are recognized by isFlowWrite(). |
apps/cloud-functions/src/contract.ts |
Introduces shared SIGN_IN_PREFIX and FLOW_WRITES derived via apiBaseUrl() for drift-resistant config. |
apps/cloud-console/src/index.ts |
Uses shared SIGN_IN_PREFIX, enables BotID client startup in production, and routes widget traffic consistently through /cloud/zitadel. |
apps/cloud-console/src/bot-check.ts |
Replaces hardcoded BotID-protect paths with shared FLOW_WRITES from the contract. |
Review effort: Balanced
Context
Summary
/cloud/zitadel/api/v1/flow…, but BotID's client still protected/cloud/zitadel/flow…. The client never marked the widget's flow writes, so the functions'checkBotId()read each one as a bot and answered403 auth.bot_suspected. A preview showed "This browser could not be verified" before the form loaded.FLOW_WRITESandSIGN_IN_PREFIXnow live in@zitadel/cloud-functions/contract. The paths are built withapiBaseUrl(), the same function the widget's API client uses, so they can't drift from what the widget sends. The add-on'sbot-check.tsandindex.tsand the functions'sign-in.tsread them from there.sign-in.spec.tschecks that every path BotID's client marks is one the functions check./cloud/zitadel, as previews do. Local builds keep the hop without the client, since only a Vercel deployment serves the challenge.Validation
moon run cloud-console:typecheck cloud-console:lint cloud-console:test cloud-functions:typecheck cloud-functions:lint cloud-functions:test: all pass (18 and 69 tests).VERCEL_ENV=production CONSOLE_BASE_PATH=/console/ CONSOLE_ADDON=../cloud-console vite buildinapps/console: the production bundle includes BotID's client and the/cloud/zitadelbase.cloud-git-claude-botid-console-signup-7ef0d8-zitadel.vercel.app): the challenge…/a-4-a/c.jsloads (200). On/console/signup,POST /cloud/zitadel/api/v1/flowreturns 201, and submitting the email step (…/flow/{id}/submit) returns 200 and shows the password step./console/loginstarts its flow with 201. Onmain's preview, the same page got 403auth.bot_suspectedwith no challenge request.curl -X POST https://preview.zitadel.com/cloud/zitadel/flow -d '{}'returns 403auth.bot_suspected. A preview can't show this withvercel curl, because its protection bypass gets through.Release notes / changeset
Notes
POST /api/v1/flowstraight to the server has no BotID check, so a script can skip the console. The signed risk signal of ADR 019 is what would close that.cloud-<hash>-zitadel.vercel.app) is not an origin of the console's project, so its flow submit answers 403 "not an origin of this project". Test on the branch alias instead.🤖 Generated with Claude Code