Repository navigation
fix(cloud): preserve Identity Center login through managed launch - #9840
Conversation
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Sound durable-identity design, but it rewrites login-flow behavior the owning Watch
The Identity Center path now depends on driving kiro-cli 2.21.2's undocumented interactive prompts (caret marker, exactly two Enter presses). A future kiro-cli that adds a prompt or drops the caret breaks pinned remote sign-in — fail-loud, but every managed Identity Center launch is down until this repo ships a driver update, with no in-product fallback (fallback is forbidden by design). SuggestionsReplace [DESIGN-REVIEWED] 4848141 |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of All checks are done: I've read the full diff, the intent file, and verified in the base tree that every remote sign-in call site is covered (wizard, launch engine, CLI — no unfixed siblings; the dashboard signin endpoint only reads the pending prompt), that the First-Principles-Verdict: CONCERNS The pty driver rests on one author-side reproduction of kiro-cli's prompting, and the failed-whoami refusal makes Builder ID users pay for an Identity Center harm. What this change shipsInventory (10 items, capped — engine-protocol versioning, whoami-parse dedup and 12 locale files also ride) — 10 justifiedIntent: an IAM Identity Center user launching a managed crew gets their organization's sign-in, verified, instead of the Builder ID portal — a FIX (deferred remainder of #6650, closing #3221).
Watch
Subtractions
[FIRST-PRINCIPLES-REVIEWED] 4848141 |
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of I have everything I need. The frontend adds a "Kiro sign-in for the crew" section (two radios, two conditional inputs, six gate/notice strings); the CLI/wizard copy asserts state and names exact recovery commands throughout. The three screenshots are hosted on the author's fork (raw.githubusercontent.com), not as GitHub user-attachments, so the workflow downloaded nothing and the sandbox blocks fetching them — none could be opened, and this fork lane has no blind read. One material finding: UX-Verdict: CONCERNS Sound copy and gating, but no screenshot could be opened (fork-hosted, not attachments) and an invalid start URL/region gives zero visible field feedback. Watch
Evidence gaps
Suggestions
[UX-REVIEWED] 4848141 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
776da9e to
da0255c
Compare
5fb46d3 to
f736bdf
Compare
7795f2b to
b40c593
Compare
Review disposition (head
|
b40c593 to
1719902
Compare
Review disposition (head
|
|
**On |
|
Correcting my note above — I had the consistency argument backwards. The validation branch that rejects a |
|
|
|
Status on |
|
@iamwhatever — could a maintainer add |
|
726 across the cloud families; isort/flake8/mypy, black (baseline-aware), comment-history, brand and ACP-boundary gates green. Frontend untouched since the last full vitest run. |
A managed EC2 crew launched through `kirocrew setup`, `kirocrew cloud launch` or the dashboard's Remote Crew form signed kiro-cli in with a bare `login --use-device-flow`: an IAM Identity Center (Pro) user was shown the Builder ID portal, and because the pre-login check was a boolean, a valid session for the WRONG account read as success. kirodotdev#6650 threaded the identity flags through the standalone `cloud login` only and recorded the managed paths as deferred. The login identity is now a durable property of the launch, not a flag on whichever `kiro-cli login` happens to run. One validated type, `KiroLoginTarget`, is carried by every sign-in entry point: - cloud/login_target.py: the model (https://<org>.awsapps.com/start only, region shape, free|pro; empty = Builder ID, byte-for-byte the old behaviour), shared whoami parsing, local identity discovery, matching. - cloud/login.py: is_logged_in(target=) means "as that identity"; remote whoami classifies match/mismatch/absent/unknown; start, resume and wait all take the target; an identity-pinned attempt never falls back to the social flow. - All nine managed call sites carry it (wizard x5, launch engine start AND resume, cli_cloud login x2); a mismatch is reported with the logout/login commands, never adopted. - LaunchJob persists it (legacy files load as Builder ID); the runner versions LaunchEngine.begin_signin so an older provisioner keeps working for the default target and fails loud for a non-default one. - POST /api/cloud/launch validates login_target at the owner boundary; GET /api/cloud/identity suggests the inherited target; the Remote Crew form gains the identity section with the Identity Center region named as distinct from the EC2 region. - cloud launch shares cloud login's three flags plus --no-inherit-identity; setup inherits by default; an inherited target missing its region is completed before provisioning or refused under --yes. Refs kirodotdev#3221, kirodotdev#6650.
|
Tests: the lookup-failure test now asserts the short cause, no raw message, and both radios unchecked until the click; new Evidence gap I cannot close from here: the screenshots are fork-hosted because a fork PR body cannot attach |
Problem / Motivation
An IAM Identity Center (Kiro Pro) user launching a managed EC2 crew — through
kirocrew setup's cloud step,kirocrew cloud launch, or the dashboard's Remote Crew launch — is shown the generic Builder ID portal, not their organization's sign-in. The remote command waskiro-cli login --use-device-flowwith no identity flags on every managed path. Worse, the pre-login check was a boolean (is_logged_in: "is some session present?"), so approving the wrong account read as success: the instance exists, the device code was valid, setup reports done, and the crew runs on the wrong license tier, model entitlement and usage pool. A resumed instance carrying a wrong-but-valid session short-circuited the same way.#6650 added
--identity-provider/--license/--idp-regionto the standalone recovery commandkirocrew cloud loginand forwarded them correctly there. It deliberately did not carry them through the managed paths — the Design and First Principles reviews on that PR recorded the gap and the approval called it deferred pending the per-invocation-flags vs instance-property decision. #3221 was nevertheless closed by that merge; this PR is the deferred remainder.Why it matters
Every Identity Center user who launches a managed crew hits this on a fresh instance (#3221 has confirmations from several organizations, CLI and dashboard). The failure is silent: nothing tells the user the crew is on the wrong identity, and the only recovery was an SSM/SSH workaround. It also defeats the point of a managed crew — "my Kiro running elsewhere" — for exactly the users on a paid tier.
What changed (motivation → approach → change)
Approach: the login identity is a durable property of the managed launch, not per-invocation flags. Flags would recreate this exact omission at every sibling call site (the wizard's verification retry and the engine's resume are the two #6650 missed). So there is now one type,
KiroLoginTarget(src/kiro_crew/cloud/login_target.py), and every sign-in entry point takes it — which makes the omission type-visible instead of a thing a reviewer has to notice.Shared model.
KiroLoginTarget(license, start_url, region)— validated for SAFETY, not shape (https on the default port; no userinfo/query/fragment; a syntactically valid hostname; control and shell metacharacters refused; region shape;free|pro; pro ⇒ start URL + region), normalized, serializable. The empty target is Builder ID and is byte-for-byte the pre-existing behaviour. Also here:parse_whoami_output(extracted from the dashboard's credit readout, which now calls it — one JSON scrape, not two),discover_local_identity(the launching machine'skiro-cli whoami --format json),identity_matches_target.cloud/login.py.is_logged_in(..., target=)means logged in as that identity: a valid session for the wrong account family isFalse. The default (Builder ID) target's family is a closed allowlist:BuilderIdand theSocial<Provider>sessions its own callback fallback produces;IamIdentityCenter,ApiKeyand an unknown type are not a match. Newremote_identity()/remote_identity_state()read the remotewhoami --format jsonand classifymatch | mismatch | absent | unknown— a transient SSM fault isunknown, never a mismatch.start_device_login/resume_login_daemon/wait_until_logged_inall taketarget=(the legacy string kwargs still work;cloud loginis unchanged for values it accepted before). An identity-pinned attempt never falls back to the social/callback flow — that is a different identity family — it surfaces the error instead.All nine managed call sites carry the target — enumerated up front, not discovered per review round:
wizard.py×5 (sign-in step, verification check/start/resume/wait),launch_engine.py×2 (_RealSigninHandlestart and resume — the handle holds the target so a device-code timeout cannot restart as Builder ID),cli_cloud.py×2 (login). The wizard and CLI both report a mismatch with the exactcloud logout && cloud login …commands rather than adopting the wrong session.Durable launch job.
LaunchJob.login_targetis persisted and round-trips; a job file written before the field loads as Builder ID.LaunchJobStore.create(login_target=). The runner callsbegin_signinthrough_begin_signin_with_target, which versions theLaunchEngineprotocol: an engine that acceptslogin_targetgets it; a downstream provisioner on the older three-argument shape keeps working for the default target, and a non-default target on such an engine fails loud (RuntimeError) rather than silently signing in as the wrong identity.Dashboard.
POST /api/cloud/launchacceptslogin_targetand validates it at the owner-only boundary (coded 400invalid_login_target; absent = Builder ID, pre-seam bodies unchanged). New owner-onlyGET /api/cloud/identityreturns the launching machine's{account_type, start_url}and a suggested target (no email; never a credential).RemoteCrewPanelgains a "Kiro sign-in for the crew" section: Builder ID / Company SSO radios, preselected from the inherited identity, start URL + Identity Center region inputs (labelled as distinct from the EC2 region), and Launch is disabled until an Identity Center target is complete.CLI.
--identity-provider/--license/--idp-regionmove to a shared helper used by bothcloud loginandcloud launch;cloud launchalso gets--no-inherit-identity. Resolution: explicit flags › inherited localwhoami› Builder ID. A localwhoamithat could not run (the binary fails to resolve, will not start, or times out) or exited nonzero without printing an identity (an expired or broken local session) leaves the identity unknown, and the command refuses — naming--identity-provider/--idp-regionand--no-inherit-identity— rather than defaulting to Builder ID; only awhoamithat ran and reported no Identity Center sign-in falls through to the default. The dashboard form applies the same rule:GET /api/cloud/identityanswersdiscovery: "unknown"with no suggested target when whoami could not answer, and the form then shows a notice, treats the checked Builder ID radio as a placeholder, and keeps Launch disabled until the user picks an identity by hand (a failed request is handled the same way). In the wizard, an identity mismatch verified at the sign-in step holds through the operational recheck unless that recheck positively confirms the right identity, so a transient SSM fault on the recheck cannot turn a wrong-identity launch into an exit-0 "not signed in" warning.--idp-regionalone completes the inherited target (it is the one fieldwhoamicannot report) rather than replacing it.kirocrew setup's hand-built launch namespace carries the same fields, so it inherits too. An inherited Identity Center target without a region is completed before anything is provisioned: asked interactively, or refused under--yeswith the flag to pass — never downgraded to Builder ID.cloud loginnow runs its flags through the samefrom_fieldsvalidation as the managed path -- a deliberate tightening, not preserved behaviour: an unsafe value (shell metacharacter,http:, userinfo) that the recovery command previously forwarded to the remote shell verbatim is refused up front with the same message the wizard gives. The host and path are NOT pinned (an Identity Center portal on GovCloud, China or a custom domain is accepted; the portal itself rejects a URL that is not one of its own). The older per-invocationidentity_provider=/license_=/idp_region=keywords onstart_device_login/resume_login_daemonare removed -- every caller passestarget=.The remote login runs under a pseudo-terminal when the identity is pinned. Found on a live launch (below): kiro-cli 2.21.2 prompts for the Identity Center start URL and region even when the flags supply them — the flags only prefill the answers — and it reads those prompts from a TTY. With the existing
nohup … </dev/nulllaunch the answers come back empty and the flow dies withinvalid value for field: region - must be a valid host labelbefore any device code is printed; Builder ID prompts for nothing, which is why the old flow never hit this. A small stdlib-only Python pty driver (_LOGIN_PTY_DRIVER, written to the instance next to the login log under the sameumask 077) runs kiro-cli, presses Enter on each prefilled prompt, strips ANSI/CR, and drops the prompt echo from the log so the echoed start URL cannot be read as the verification URL;parse_login_output(ignore_url=)guards the same thing from the parsing side. The Builder ID launch is byte-identical to before.Alternatives considered: per-invocation flags on
cloud launchonly (the shape #6650 took forcloud login) — rejected for the reason above; inferring the Kiro identity from the AWS provisioning profile — rejected, the two identities are unrelated (a crew provisions correctly in any AWS account while signing in as the wrong Kiro account).Tests
test/test_cloud_login_target.py(53) — one class per boundary #6650 left open:from_dictof a malformed persisted target falls back to default.is_logged_in(target=)False and statemismatch; matching identity short-circuits;absentvsunknownkept distinct; target flags reach the remote command on both start and resume (and via the legacy kwargs); the default target emits exactly the old command; an identity-pinned attempt never calls the callback fallback while the default still may; a pinned login runs under the pty driver (written afterumask 077, cleaned up with the log) while Builder ID keeps the plainnohup;parse_login_outputignores the pinned start URL; and a real pty run of the driver against a fake kiro-cli that prompts like 2.21.2 answers both prompts, emits no prompt echo / start URL / ANSI, and yields a parseable code +user_code=URL.{license, start_url, region}._RealSigninHandleforwards the target on start, resume and poll; the runner passes it to a target-aware engine, and refuses a non-default target on a legacy engine while leaving the default path untouched.invalid_login_targetwith nothing persisted; non-owner 403 before parsing;/api/cloud/identityowner-only, suggests the target, omits email.--idp-regionalone completes it (and is still refused with nothing to attach to);--no-inherit-identityand a Builder ID local identity both yield the default;cloud launchthreads the target into the wizard; both parsers accept the shared flags; the setup namespace inherits.--yeswith an un-regioned Identity Center target exits 2 naming--idp-region, provisioning nothing.All 591 cloud tests (
test/test_cloud_*.py) pass; black / flake8 / isort / mypy / comment-history gates green.website/src/test/RemoteCrewPanel.test.tsx(+2): the inherited Identity Center identity is preselected and named, Launch is disabled until the region is entered, and the body carrieslogin_target; overriding back to Builder ID sends no target. 104/104 in the panel's three test files.Manual verification
Live launch from this branch into a disposable AWS account (
cloud launch --size light --idp-region <region> --new --keep-on-failure, launching machine signed in to Identity Center):-> The crew will sign in as IAM Identity Center (https://<org>.awsapps.com/start, <region>).printed before any provisioning. (The first attempt exposed the--idp-region-alone resolver bug in item 6 — "an Identity Center region without a start URL is meaningless" — fixed and covered by test.)CREATE_COMPLETE, instance healthy, KiroCrew installed.kiro-cli did not produce a device-code prompt for IAM Identity Center (…). Diagnosed on the kept instance over SSM: kiro-cli 2.21.2's log held onlyerror: failed to construct request;-vvshowedcalled input while stdout is not a terminal×2 theninvalid value for field: region - must be a valid host label; the same command under a pty showed? Enter Start URL › https://<org>.awsapps.com/startwaiting; a Builder ID control printed its code normally; and driving the pty with Enter on both prompts producedConfirm the following code in the browser / Code: XXXX-XXXXfor the Identity Center portal. That driver is the fix._device_login_commandrenders for the pinned target, delivered throughssm.run_command's wrapper): captured log is exactlyConfirm the following code in the browser / Code: XXXX-XXXX / Open this URL: https://<org>.awsapps.com/start/#/device?user_code=…— the org portal, zero prompt echo; driver + kiro-cli child alive and polling under the pid in the pid file; log, driver and pid file all0600 ec2-user. After approving the code in a browser:whoamion the box reportsIamIdentityCenterwith the org start URL, and the driver and its child have exited.remote_identity_state/is_logged_in(target=)against that live session): pinned org target →match/ True; a different org's start URL →mismatch/ False; the default Builder ID target →mismatch/ False (every supplied target is verified, the default included — a reused instance's Identity Center session is not adopted by a Builder-ID launch; only a caller passing NO target asks the legacy "some session" question). Before the approval all three readabsent/ False.kirocrew setup(sameKiroLoginTargetplumbing, covered by handler/CLI tests), a device-code timeout mid-launch (engine resume covered by test), and a gateway restart mid-sign-in.Screenshots / video
Captured with scripted Playwright against an isolated gateway built from this branch (
instances.enabled=trueseeded; the launching host is an Identity Center user, so Company SSO is preselected — the start URL shown is a typed placeholder, not a real portal). Files undertemp-screenshots/cloud-idp/, pinned to this commit.Company SSO preselected from the host's identity; region missing → Launch gated with the identity message:
Builder ID override — the Identity Center fields collapse:
Company SSO complete (region entered — identity message clears)
Related Issues
Refs #3221 (closed by #6650; reopen requested there — this PR is the deferred managed-flow remainder). Refs #6650.
Pattern harvest
Rule candidate: review-prompt
Pattern: an authentication/identity target is threaded through one entry point (
cloud login) but omitted from sibling orchestration and resume paths that reach the same remote command — check every caller of the sign-in primitive, and prefer a required structured type over optional string triples so the omission is a type error.Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement