Skip to content

feat(auth): profile selector for multi-profile Kiro sign-in - #29167

Open
Skripd wants to merge 2 commits into
kirodotdev:mainfrom
Skripd:feat/kas-profile-selector
Open

Skripd wants to merge 2 commits into
kirodotdev:mainfrom
Skripd:feat/kas-profile-selector

Conversation

@Skripd

@Skripd Skripd commented Nov 3, 2026

Copy link
Copy Markdown

Problem / Motivation

Goal: When a Kiro sign-in resolves more than one profile, let the user choose which one their agents run as, show which profile is active afterwards, and tell a user with no entitled profile what actually happened.

Two gaps in the dashboard Kiro sign-in (Settings -> Agent Harness -> Kiro sign-in):

Why it matters

Users on multi-profile accounts had no way to pick their profile from the dashboard (kiro-cli already offers this), so agents could run as the wrong one with no indication which. And the misleading error in #28904 sent users debugging an approval that had actually worked; the real cause - no profile assigned - was never surfaced, so they could not act on it (the fix is an admin assignment, which the message now names).

Not a goal

  • Changing how profiles are discovered across control planes - that is the stacked discovery fix (fix(auth): resolve Kiro profiles by control-plane discovery, not region map #29049); this PR consumes its merged profile list.
  • Letting the user switch profile without a fresh sign-in - selection happens during sign-in; changing it later is a re-sign-in, as the chooser copy says.
  • Editing the Kiro Agent backend's "Default." description line - that names the harness, not the profile; the active profile is shown in the sign-in summary instead.

What changed (motivation -> approach -> change)

  • Goal: a profile choice when there is one, a clear active-profile readout, and an honest no-profile message.
  • Approach: the sign-in poll already resolves the full profile set; rather than auto-pick, pause the login on >1 and let the dashboard complete it with the chosen ARN. Keep the no-profile and control-plane-failure cases as distinct coded outcomes so the UI can word each correctly. Surface the chosen profile on the signed-in card.
  • Change, by layer:
    • Backend (auth/service.py): the IdC poll branches on the resolved profile count - 0 returns error + code:"no_profiles" + the probed region; 1 auto-completes as before; >1 holds the authorized token in memory on the pending login and returns a new non-terminal select_profile status carrying the choices. select_profile(login_id, arn) validates the ARN against the offered set (UnknownProfileError otherwise) and finishes through the existing persist step. A control-plane failure now carries code:"profile_resolution_failed", distinct from no_profiles. The chosen profile's human name is stored in token.extra so the card can name it; status() exposes profile_arn, profile_name, and profile_region (derived from the ARN), all token-free.
    • API (dashboard/handlers/kas_login.py, route in routes/realtime.py, api/client/onboarding.ts, api/client.ts): new POST /api/kas-login/select-profile; KasLoginPollResult gains the select_profile status, profiles, region, and codes; KasLoginStatus gains the three optional profile fields; new KasLoginProfileChoice type and kasLoginSelectProfile().
    • UI (components/KasLoginGate.tsx, pages/developer/KiroSignInCard.tsx, i18n/locales/en.manual.json): a ProfileChooser step (one radio per profile, name + region from the ARN, first preselected so a single confirm signs in) renders when the poll returns select_profile; the problem screen shows an amber "signed in, but no Kiro profile" message (not the red approval-failed one) for no_profiles, naming the region and the admin remedy; the signed-in summary shows Profile: <name> (<region>) when a profile is present.

Backwards compatibility

Compatible: no existing wire field is removed, renamed, or made stricter. KasLoginPollResult.status gains a new member (select_profile) that only a multi-profile IdC sign-in produces; existing single-profile and error flows are unchanged. The three new KasLoginStatus profile fields are OPTIONAL in the type, so a client reading an older gateway (which does not send them) still type-checks, and the UI guards on their presence. POST /api/kas-login/select-profile is a new route; nothing calls it on an old client.

Removes nothing: no capability, record, key, or path is withdrawn or tightened; the change only adds a mid-sign-in state and three read-only status fields.

Tests

Backend (test/test_kas_login_service.py):

  • test_poll_oidc_multi_profile_offers_a_choice - profiles on different control planes are merged and offered; select_profile completes with the chosen ARN and stores its name.
  • test_poll_oidc_dedupes_a_profile_seen_on_two_hosts - a profile reported by both hosts is offered once; a lone profile still auto-completes.
  • test_select_profile_rejects_an_unoffered_arn, test_select_profile_on_unknown_login_raises - selection validation.
  • test_poll_idc_with_no_profiles_is_error_and_saves_nothing / ..._control_plane_failure_is_error - the two distinct error codes.
  • test_status_reports_active_kiro_profile / test_status_profile_fields_blank_without_a_kiro_profile - the three status fields.

Frontend:

  • KasLoginGate.test.tsx - chooser offers both profiles with regions, first preselected, select_profile called with the chosen ARN; no_profiles shows the honest message (and NOT the generic one); a non-profile terminal error keeps the generic message.
  • KiroSignInCard.test.tsx - the active-profile line shows name + region when present, and is absent for a social sign-in.

Proof: not provable -- fix PR proof (prove.py) applies to the discovery fix: PR; this is a feat: PR whose tests assert new behavior that did not exist before, so a revert-the-production-hunk proof does not apply.

Manual verification

Verified end to end against a live gateway built from this branch using a real IAM Identity Center account (region eu-west-1) that resolves two profiles (us-east-1 and eu-central-1 on the same account):

  • The dashboard sign-in showed the profile chooser with both profiles and their regions; picking eu-central-1 completed the login.
  • The signed-in card then showed Profile: KiroProfile-eu-central-1 (eu-central-1).
  • An account with no entitled profile showed the amber "signed in, but no Kiro profile" screen naming the probed region, not the approval-failed message.

Screenshots / video

  • Profile chooser (two profiles, us-east-1 + eu-central-1).
redacted_cli_selector Screenshot 2026-11-03 124601 - Signed-in card showing the active profile line. Screenshot 2026-11-03 130522 - The honest "signed in, but no Kiro profile" error (#28904). Screenshot 2026-11-03 130902

Related Issues

Closes #28904 #29139
Part of #29049 issue, if a new selector issue is opened

Sibling sweep

N/A - feat PR, not a fix/revert.

Pattern harvest

N/A - feat PR, not a fix/revert.

@Skripd
Skripd requested review from a team and KiroCrewCaptain as code owners November 3, 2026 12:38
@Skripd
Skripd requested a review from cruisercohen November 3, 2026 12:38
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 3, 2026
@Skripd
Skripd force-pushed the feat/kas-profile-selector branch from 68f996a to 8081f11 Compare November 3, 2026 22:30
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 7, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Status check from a stale-PR sweep. Two things changed on main since this was opened:

What is left of value is the profile selector itself. Porting it means rebuilding it on main's ProfileListing API, and deciding whether discovery should merge profiles across control planes (this PR) or keep main's first-host-wins rule. That is a design call for a maintainer and the author, so I have not pushed a rebase. @Skripd, if you want to continue, a rebase onto main that drops 1071595 and states which discovery rule it relies on would be the next step.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IdC sign-in fails with "no available Kiro profiles" when the Kiro profile is in a different region than the Identity Center instance

2 participants