Repository navigation
feat(cli): connect Gateweave ID to Track - #18
Conversation
`gateweave connect id track` takes the recorded ID and Track deployments, shows both addresses and every setting it will set, and waits for a yes. It sets ID's BETTER_AUTH_URL and OIDC_PAIRWISE_SECRET when unset, registers Track with ID's own apps:add against the deployed database, and gives Track OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_PROVIDER_NAME, OIDC_CLIENT_SECRET and, when unset, BETTER_AUTH_URL. Every value goes to `wrangler secret put` on stdin. The pairwise secret is the one value to keep: it goes to a new file outside the working directory (--keep-secret-at, written new-only with mode 600), or is shown once on a terminal; with --json or without a terminal the command asks for the file instead. apps:add output stays in memory, and output of another form stops the run without showing any of it. Everything shown passes through the shared output guard. hideSecrets also hides `client secret: …`, ID's gwid_cs_ prefix and OIDC_*_SECRET assignments, and the guard's new `remember` adds the values a run generates or captures, so even a child that echoes one is filtered. A second run finds Track's registration with one fixed SELECT on ID's database and registers nothing twice. A registration without Track's secret, or a Track with another provider, stops with what to do. doctor track and doctor id report the connection when one is set up or recorded; the record keeps the client id, never a secret. Invariant 5 in AGENTS.md now names connect as its one exception, and the source rule allows randomness and `secret put` in connect.ts only.
Reading both roots is a superset of Wrangler's own rule. The folders are read only to learn values to hide, so hiding one more costs nothing, and missing the one Wrangler uses would print a token.
- --no-account-name, as deploy has it: the plan, errors and --json name the account by id. - "Already set" is proof: secrets and every binding of the deployed version, text variables included. A failed look, listings that disagree or a split deployment stop the run. A visible button is no longer taken for a setting, and a provider name that cannot be read stops the run instead of loosening the check. - The plan names ID's database by name and id; a deployment recorded as external is used only when named. - The keep path is decided after knowing whether a value is made, made new without following a link, and checked again where its folder really leads once opened. The terminal copy comes before the put. - apps:add is read only in its exact three-line form, and nothing it printed reaches an error. - The registration query also matches the app id, and quotes its address; the recovery covers a Track that still holds OIDC settings. - The client id is on record before Track is given anything, and the client secret is tried three times. - One run at a time, with a lock file beside the record. - Children start without NODE_DEBUG or WRANGLER_LOG_SANITIZE, and every command stops while NODE_DEBUG is set. - Doctor checks at the connection's addresses, looks for the exact button and the issuer in Track's page policy, says the client id cannot be read, and doctor id reads ID's database for it. - A URL with a name and password is not repeated. - The workers.dev warning names the calling Worker that lacks global_fetch_strictly_public.
…ng means - Once the pairwise put was tried, the keep file is never removed. A put that failed with a listing that failed too is reported as unknown: the value may be set, keep the file and run again. - A lock that is there is never cleared, whatever its age. The run stops with its path, the holder's pid and start time, and whether that pid is alive on this machine. - Track's OIDC_CLIENT_ID or OIDC_ISSUER that the record does not show this tool set stops the run before any change, with the recovery steps. The record names each Track setting this tool set, before it is put, and doctor says "this tool gave it" only from that. - A text OIDC_ISSUER is compared whole with the issuer, path included. - Every message strips a name and password from any address in it, read or given, through one helper. - Each workers.dev warning speaks only for its own direction. - Button names are compared with HTML character references decoded. - apps:add output is matched as captured, line endings aside; only the secret's own prefix is refused as a client id. - The keep file is written in the folder the plan checked, or nowhere. - A printed rerun repeats the names and addresses given. - The client-secret-not-set stop says the registration needs cleaning up.
…does not make it this tool's
…finishes - A Track setting is recorded as pending while its put is tried and as this tool's only once Wrangler or Track's list confirms it, the client secret included. A failed put leaves no claim, so neither connect nor doctor takes a value set by someone else for this tool's. - Track's text OIDC_CLIENT_ID and OIDC_ISSUER that match ID's registration are consistent and kept. The advice to restore a known client secret names the settings that cannot be shown to match, so following it and running again finishes. - Credentials are taken out of an address by its structure: everything up to the last "@" before the host ends, whatever the password holds. - A printed rerun also repeats --keep-secret-at with its path, --yes and --json when they were given.
…quoted for the shell
- Userinfo is taken out of every scheme:// on its own: an authority ends
at "/", "?", "#", white space or the next address, so two addresses
joined by "," or ";" both lose their name and password.
- The printed rerun quotes each argument that needs it: POSIX single
quotes off Windows ("'" as '\''), double quotes on Windows.
…dows quoting limit
- Credentials are taken out after each "://", whatever comes before it,
so an address right after a port (":8443https://...") loses its name
and password too.
- The README says that inside the double quotes printed on Windows,
PowerShell still expands $name and cmd %name%, so such a path must be
edited by hand before pasting.
There was a problem hiding this comment.
Exact-head independent review of 0158faa80366165ac20edcd692c71e5ed564652c against merge-base 55e5309901e7be10e153019ae102eda4038edcc8 (current main 5dd323fb1dabf88d2a85dad60372798403a20ce8 adds only the secret-scan infrastructure after that base).
Verification performed: clean exact-head Linux worktree, pnpm install --frozen-lockfile --ignore-scripts, then pnpm verify: 342/342 tests passed and the production build completed. No Cloudflare/provider call, live rehearsal, push or merge. This review is source plus synthetic-test evidence only.
Requesting changes before the live rehearsal candidate is treated as sound:
-
Existing registrations are not verified for the required back-channel logout URI.
trackRegistrationSql()selects onlyclient_idand matches only the callback URI inredirect_uris(packages/cli/src/registration.ts), andconnect()then treats any such row as the existing registration (packages/cli/src/connect.tsaround the lookup). A manually or previously created Track client with the right callback but a missing or differentbackchannel_logout_uriis adopted as complete; the command then reports the connection checked even though ID will not send Track the logout events the command is meant to configure. Because the client secret cannot be read again, silently deleting/re-registering is not safe either. The lookup needs to read and validate the registration shape that matters (at minimum the back-channel logout URI, and ideally auth/PKCE expectations), then either prove it correct or stop with explicit recovery instructions. A focused fixture should cover missing and wrong logout URIs. -
A pre-existing secret
BETTER_AUTH_URLon Track is treated as correct although its value cannot be read. The code only compares Track's address whenBETTER_AUTH_URLis a text variable; when it is a secret, it is counted as already set and left alone. The final checks prove only that the sign-in page/button and OIDC issuer exist, not that Track's configured base URL is the address whose callback/logout URIs were registered. A wrong secret value can therefore produce a successful-looking “connected” result and a broken sign-in flow. If the value cannot be proven, the command needs an explicit refusal or fixed inconclusive evidence and recovery path rather than success. This should be pinned for both first connect and rerun paths. -
The connect path starts child processes without the bounded timeouts the runner now supports. Unlike deploy/doctor,
connect.tscallssys.runfor git/npx, every Wrangler invocation throughwranglerAt, dependency installation andapps:addwithoutPROCESS_TIMEOUTSor another deadline. In the real system those omissions mean a stuck network/API/process can hang the connect command indefinitely. Please thread appropriate version/listing/install/deploy bounds through these calls and add a never-answering-child regression for the connect path.
The careful secret filtering, exact apps:add output parsing, registration-before-first-Track-put ordering, lock behavior, ownership tracking and synthetic recovery coverage are otherwise strong, but the three points above affect whether the command can honestly prove or safely finish the connection.
There was a problem hiding this comment.
Approved at exact head 65a538c0cf955fcc68d3c938b529d32f39bc84af, re-reviewed against prior head 0158faa80366165ac20edcd692c71e5ed564652c and merge-base 55e5309901e7be10e153019ae102eda4038edcc8. The three findings from my prior exact-head review are addressed; I found no material source blocker in the delta.
Independent verification here: clean exact-head worktree, focused connect/registration/system tests 67/67 passed, full suite 349/349 passed, package typecheck passed, and exact prior-to-new-head Gitleaks scan found no leaks. No provider call, live rehearsal, write, deployment or merge.
Finding resolution:
- Stored logout URI before adoption:
trackRegistrationSql()now selectsbackchannel_logout_uri;readTrackRegistrations()preserves missing/non-string values instead of collapsing rows into bare IDs;connect()refuses a missing, wrong-type, wrong or trailing-slash-different URI before registration adoption, random generation or writes. Focused fixtures cover those variants and successful adoption once the stored URI exactly matches. - Secret Track URL proof: a secret-held Track
BETTER_AUTH_URLis no longer assumed correct. Before writes, connect requires the selected address's public protected-resource metadata to answer 200 withresourceexactly equal to<selected-address>/mcp. Track derives that resource from its pinnedBETTER_AUTH_URL, and the real CLI fetcher uses manual redirect handling, so a 302 cannot satisfy the proof. Tests cover first connect and rerun, missing/malformed/other-path/no-resource/redirect answers, no writes, no record mutation and no hidden-address disclosure. A correct existing secret is left in place and the first connect can complete safely. - Bounded children: every direct connect child is bounded: version probes, release listing, clone, all Wrangler reads/writes through
wranglerAt, dependency installation and providerapps:addregistration. The tests assert the timeout category on every connect child and exercise a hungapps:add, including bounded cleanup, no secret/token output exposure and no duplicate registration on retry.
Remaining boundary: this is synthetic/source evidence only. I did not perform the separate empty-account live rehearsal. The hosted Ubuntu and Windows required checks are green. The hosted history secret scan is red on earlier synthetic test fixtures already in this PR's history; the exact new correction commit itself scans cleanly and the red findings are fixture-shaped test constants rather than evidence of a real credential, but that separate scan gate still needs its normal resolution before merge.
There was a problem hiding this comment.
Approved at exact head 30c98019e6d34436677fcce7787629bce8c30aa8. The implementation is unchanged from my approved exact head 65a538c0cf955fcc68d3c938b529d32f39bc84af, so this review reuses that evidence and covers only the two-file scanner delta.
Narrow verification here:
- The delta is exactly
.gitleaksignoreplus thepackages/cli/test/system.test.tsstdin fixture. - The fixture is now explicitly synthetic (
["synthetic", "stdin", "fixture", "value"].join("-")) rather than credential-shaped. .gitleaksignorecontains exactly three commit/path/rule/line fingerprints for the historical synthetic fixtures. It does not contain a blanket path, rule or repository exception, and it does not ignore the transient merge-commit fingerprint.- With pinned Gitleaks 8.30.1 and the current shared config, scanning the exact head history reported 36 commits scanned and no leaks.
- A temporary local probe commit adding a fresh credential-shaped synthetic test value was still detected (1 leak), confirming the exact fingerprints do not disable detection generally. The probe was local-only and removed.
- Hosted checks are green at this head, including required Ubuntu and Windows checks and the Gitleaks scan.
No unrelated implementation lanes were rerun. No provider/live rehearsal, write, deployment or merge.
…ect-review-fixes-20261204
|
Rehearsed the CLI runtime from The synchronization with |
What changed
Add
gateweave connect id trackto set up ID as the sign-in provider for Track. The command shows the account, deployments and settings before asking to proceed. It registers Track through ID's own registration flow, configures Track, and checks the connection.Verification
pnpm verifypassed on Windows with 322 tests and a production build.