Repository navigation
fix(auth): let KIRO_CPS_URL and KIRO_OIDC_SCOPE_PREFIX reach a gamma IdC profile - #36242
tim-finnigan wants to merge 1 commit into
Conversation
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
18e6bdc to
77a21d6
Compare
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: both variables add an opt-in path, the unset path is the same as main, and the policy host stays on the built-in table. Notes
[DESIGN-REVIEWED] e5b4b75 Description read[DESCRIPTION-READ] f96cbe07293d6c70370df851c522e3dae5914c1e8cb889f567e519b4b5fb1053 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Both variables are off by default and come from the frozen Goal; nothing blocks. Item 1 is a second way to name a control-plane URL. The open #36188 already offers the other way. Not checked: the claim that the kiro-cli 3.3.0 binary has an Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: a gamma Identity Center user can sign in by naming their control plane and its OIDC scope prefix. FIX (#36190).
[FIRST-PRINCIPLES-REVIEWED] e5b4b75 Description read[DESCRIPTION-READ] 4ef24414045456878c78bae85289a1a50bbb946ec42f7354f0beb7f6172fe5df That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
77a21d6 to
19b197b
Compare
…IdC profile Sign-in only ever asked the production control planes, so an Identity Center account whose profile lives on a gamma control plane found no profile. KIRO_CPS_URL, when it is an https URL, replaces the host table for the sign-in profile listing only: the listing asks only that host. control_plane_url(), which the LTS policy fetch uses, never reads it, so the environment cannot choose where the organisation's policy comes from. Any other value, including one that does not parse, is ignored with a warning, and an LTS build ignores the variable altogether. That control plane also lists profiles only for scopes under its own prefix. KIRO_OIDC_SCOPE_PREFIX, like kiro-cli's api.oidc.scopePrefix, replaces the public prefix of every SSO-OIDC scope at registration. The scopes are recorded on the token, carried through refresh, and a stored registration is reused only for the same scopes. A value that is not lowercase letters and underscores is ignored with a warning. Unset, both behave exactly as before. Closes #36190
19b197b to
e5b4b75
Compare
This is one of two alternative fixes for the same bug (#36190); only one should land. The other is #36188, which asks the relay viewer's
tunnel.relay_viewer_cps_urlfirst.Problem / Motivation
Goal: An Identity Center user whose Kiro profile lives on a non-production control plane (gamma) can sign in by naming that control plane (
KIRO_CPS_URL) and the OIDC scope prefix it lists profiles under (KIRO_OIDC_SCOPE_PREFIX). Gamma sign-in needs both: the host alone was asked and answered, but listed zero profiles for a token holding the public scopes.Sign-in approves the device code, then reports "no Kiro profile".
list_available_profilesonly ever asks the production hosts in_CPS_ENDPOINTS, andcontrol_plane_url()can only return one of them, so a profile only gamma lists is never found.Why it matters
Anyone testing against a gamma account (Tim reproduced it today) cannot sign in at all.
Not a goal
KIRO_OIDC_SCOPE_PREFIXis unset.KIRO_CPS_URLis unset.What changed (motivation → approach → change)
Symptom: "no Kiro profile" for a gamma IdC user. Root cause: the control-plane host is hard-coded to the production table. Change:
KIRO_CPS_URL, read insrc/kiro_crew/auth/login/control_plane.pythe same wayendpoints.pyreadsKIRO_AUTH_PORTAL_URL. No existingKIRO_*variable names a CPS, control-plane or management URL on main, so this adds a new one.https://URL: the sign-in profile listing (control_plane_urls(), solist_available_profiles()) asks only that host.control_plane_url()is not affected.urlsplitcannot parse): ignored, with one warning per distinct value, since the bearer token is sent to it.Callers:
control_plane_urlhas one other caller, the LTS policy fetch atsrc/kiro_crew/platform/enterprise_policy_fetch.py:171. It deliberately does NOT followKIRO_CPS_URL: a locally set host could otherwise answer the policy read and replace the administrator's policy ceiling (RFC rfc-crew-lts-edition, D2), socontrol_plane_url()always answers from the built-in table._CPS_ENDPOINTSis read only insidecontrol_plane.py.docs/system-specs/modules/kas-auth.mddocuments both variables.Scope prefix (added at a reviewer's request, so both alternatives can sign a gamma user in): a gamma control plane lists profiles only for scopes under its own prefix, so a token holding the public
codewhisperer:scopes gets zero profiles there.KIRO_OIDC_SCOPE_PREFIXmirrors kiro-cli'sapi.oidc.scopePrefixsetting (the setting name is in the kiro-cli 3.3.0 binary): set, it replaces thecodewhispererprefix of every SSO-OIDC scope (Builder ID and Identity Center) atRegisterClient, viaoidc_scopes()insrc/kiro_crew/auth/login/endpoints.py.[a-z_]{1,64}, so no colon or space can add or split a scope); anything else is ignored with one warning per distinct value. The check is a token pattern, not a list of accepted values.extra["oidc_scopes"](only when not the public ones, so a public-scope token is stored exactly as before), andrefresh.pyalready carriesextraforward.stored_clientreuses a registration only for a sign-in asking the same scopes, so changing the prefix registers a new client. This is the same mechanism fix(auth): sign in to the relay viewer's control plane with its own profile and scopes #36188 uses, so the two options stay comparable; they differ only in what picks the scopes (this env var vs the relay viewer's CPS setting).OIDC_SCOPEShas no other reader:builder_id.register_clientis the only place scopes are sent.Rebase note: main's #35620 moved the host list into
control_plane_urls(), which also names the hosts in the "no profile" message (src/kiro_crew/auth/service.py). The override now lives there, so that message names the override too.Desktop app pass-through: the Electron gateway supervisor passes its own process environment to the gateway it spawns, minus
KIROCREW_PORT(website/electron/gateway-supervisor.js:860, spread into the spawn env at:930-931, kept bybuildGatewayEnvironmentatwebsite/electron/gateway-env.js:111-114). A macOS app opened from Finder or the Dock gets launchd's environment, not the shell's, so a tester has to start the app binary from a terminal:If a gateway is already running on the port, the app adopts it and the variable never reaches it, so quit Kiro Crew fully first.
Backwards compatibility
Compatible: with
KIRO_CPS_URLandKIRO_OIDC_SCOPE_PREFIXunset, the hosts asked, their order, the scopes registered and the stored token are exactly as on main. A stored registration with no recorded scopes reads as the public ones, so existing sign-ins keep reusing theirs.Removes nothing: both variables only add a path; the production table, the fallback region and
OIDC_SCOPESare untouched.Tests
test_kiro_cps_url_names_the_only_listing_host_but_not_the_region_host: set, the listing asks only the override for any region, andcontrol_plane_url()keeps the table.test_kiro_cps_url_is_ignored_in_an_lts_build: an LTS build ignores the variable and warns.test_kiro_cps_url_that_is_not_https_is_ignored_with_a_warning: http, host-less and unparseable (https://[::1) values are ignored and warned about.test_kiro_cps_url_unset_still_asks_every_table_host: unset, the listing asks the production hosts as today.test_kiro_cps_url_listing_asks_only_that_host: set, the listing asks the override and nothing else.TestSuccess::test_kiro_cps_url_does_not_move_the_policy_read: withKIRO_CPS_URLset, the policy fetch still posts to the built-in host.TestSuccess::test_the_policy_read_ignores_an_accepted_cps_override: even an override the listing accepts (LTS check bypassed) does not reach the policy host.test_scope_prefix_unset_or_blank_keeps_the_public_scopes: unset or blank givesOIDC_SCOPES, and pins their literal values.test_scope_prefix_replaces_the_public_prefix: a made-up prefix (acme_test) replacescodewhispereron all three scopes.test_scope_prefix_that_is_not_a_token_is_ignored_with_a_warning: colon, space, uppercase, digit, hyphen and over-length values are ignored and warned about.test_a_sign_in_registers_for_the_configured_scopes(Builder ID and IdC, unset and set): unset reuses the stored public registration; set refuses it and registers the prefixed scopes.test_the_registrations_scopes_ride_from_sign_in_through_refresh: scopes go out at registration only, are recorded on the stored token, survive refresh, and gate reuse.test_a_public_scope_sign_in_is_stored_as_before: public scopes are sent and nothing is added toextra.Proof: PROVEN test/test_enterprise_policy_fetch.py::TestSuccess::test_the_policy_read_ignores_an_accepted_cps_override, test/test_kas_login_service.py::test_kiro_cps_url_names_the_only_listing_host_but_not_the_region_host (head e5b4b75)
Checked by hand rather than with prove.py, which reverts to main and so cannot isolate this round: the two tests above fail with the previous head's
control_plane.py(override insidecontrol_plane_url). For the scope prefix: withendpoints.py,builder_id.pyandservice.pytaken from main and the tests kept, 13 of the 14 scope tests fail; the one that passes istest_a_public_scope_sign_in_is_stored_as_before, which pins unchanged behaviour.Local gates, kept to auth/login and policy-fetch tests (#36188 has priority on local runs): the six auth/login and policy-fetch test files pass (360 tests). mypy is clean on the four touched modules, black and flake8 on touched files, and
scripts/docs-lint.shpasses. I did not run the full backend suite or mypy across all ofsrc; CI owns those.Manual verification
Not yet run against gamma with this PR. A patched nightly copy for Tim to test it on was built before the scope prefix was added, so it carries
KIRO_CPS_URLonly and has not been rebuilt.Related Issues
Closes #36190. Alternative: #36188.
Sibling sweep
Swept:
git grep -nE "control_plane_url|_CPS_ENDPOINTS|management\.[a-z0-9-]+\.kiro\.dev" -- srcSwept:
git grep -nE "OIDC_SCOPES|register_client|stored_client" -- srcSibling: src/kiro_crew/auth/service.py -- changed here (the only
register_clientandstored_clientcaller now passes the configured scopes)Sibling: src/kiro_crew/platform/enterprise_policy_fetch.py:171 -- not affected -- policy fetch stays on the built-in table by design; two tests pin it
Pattern harvest
Not generalizable: the auth portal already has its env override; the control-plane host and the scope prefix were the two non-production settings kiro-cli has that Kiro Crew lacked.
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.