Skip to content

fix(kas-auth): offer the kiro-cli account switch only to the owner - #37275

Merged
buluoray merged 1 commit into
mainfrom
crew/slack/kas-sources-owner-check
Nov 14, 2026
Merged

buluoray merged 1 commit into
mainfrom
crew/slack/kas-sources-owner-check

Conversation

@buluoray

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Only the dashboard owner sees Use the Kiro CLI account on the Kiro sign-in card, because only the owner can run the sign-out it needs.

A teammate on a shared dashboard who is not the owner sees Use the Kiro CLI account when the Kiro Crew and Kiro CLI sign-ins are different accounts. Clicking it runs POST /api/kas-login/logout, which is owner-only, so they get a 403 and the button does nothing. KiroCrewCaptain raised this in its review of #36324 (review 5903662688), and I took it as a follow-up.

Why it matters

A button that always fails for the person who sees it is a dead end. It also suggests they may change a sign-in that only the owner controls.

Not a goal

  • Changing what the owner sees, or any other part of the card's notices.
  • Changing how same_account decides; this PR only documents and pins its current answer for Identity Center and External IdP.

What changed (motivation → approach → change)

  • Symptom: a non-owner is offered a switch whose sign-out answers 403.
  • Cause: kas_login_sources.api_kas_login_sources computed can_use_kiro_cli without the owner value it already reads for the email field.
  • Change: can_use_kiro_cli now also requires owner. On LTS the account-lock read is skipped for a non-owner, since the answer is already False.
  • Also from the same review: lts_sign_in.same_account's docstring now says that equal Identity Center or External IdP profile ARNs count as one account even though one organization can share that ARN. The cost is a missing two-accounts notice, never a wrong one. A test pins that answer.
  • kas-auth.md says the button is offered only to the owner.

Backwards compatibility

Compatible: the response keeps the same fields; for a non-owner can_use_kiro_cli is now False, and that button could never work for them.

Removes nothing: the owner keeps the button; a non-owner loses only a control that always failed with 403.

Tests

  • test_only_the_owner_is_offered_the_kiro_cli_account: a non-owner request with two different accounts gets can_use_kiro_cli False.
  • test_equal_organization_profile_arns_count_as_one_account[identity_center|external_idp]: pins same_account returning True for equal ARNs of those kinds.
  • test_kas_login_sources.py and test_lts_sign_in.py: 138 passed.

Proof: PROVEN test/test_kas_login_sources.py::test_only_the_owner_is_offered_the_kiro_cli_account (head bfcf1d5)

Manual verification

N/A — unit coverage sufficient: the change is one boolean term in a JSON status read, and the handler test drives the real handler with an owner and a non-owner request.

Related Issues

Follow-up to #36324 (KiroCrewCaptain review 5903662688, optional notes).

Sibling sweep

Swept: git grep -n "kas-login/logout|is_owner_dashboard_request" -- src/kiro_crew/dashboard/handlers/kas_login*.py
Sibling: src/kiro_crew/dashboard/handlers/kas_login_sources.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/kas_login.py -- not affected -- the logout route itself already refuses non-owners

Pattern harvest

Not generalizable: one status field that offers an owner-only action; the route it points at already enforces the owner check.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 14, 2026 16:43
@buluoray
buluoray requested a review from CrysisDeu November 14, 2026 16:43
@buluoray
buluoray enabled auto-merge (squash) November 14, 2026 16:43
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 32fc5d4e4d5a91a9404c2feb975fc3af26c4e1f0 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 32fc5d4e4d5a91a9404c2feb975fc3af26c4e1f0 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix adds owner to the existing can_use_kiro_cli check, at the place the value is computed. The frontend has no second owner check that this would duplicate.

Notes

  • Item 3 — rides along: the same_account docstring and its test pin today's behaviour. They are not part of the owner fix, but the description declares them (Also from the same review) and they change nothing.

What this change ships

Inventory (4 items) — 3 justified

Intent: stop showing a teammate who isn't the owner a "Use the Kiro CLI account" button that always fails with a 403. This is a FIX.

  1. Non-owners no longer see "Use the Kiro CLI account" on the sign-in card — justified
  2. On LTS, the account-lock read is skipped for non-owner requests — justified
  3. The same_account docstring and test now pin that equal Identity Center / External IdP profile ARNs count as one account — rides along, declared, no behaviour change
  4. The kas-auth spec says only the owner is offered the button — justified

[FIRST-PRINCIPLES-REVIEWED] 32fc5d4

Description read

[DESCRIPTION-READ] 21bf36ebf1ee6bdf05439d6a98efdfdd50f75daee1b0e0a5aef4289a6812e365

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 32fc5d4e4d5a91a9404c2feb975fc3af26c4e1f0 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this is the right fix in the right place. The owner check moves into the status field that offers the switch, and the frontend already handles can_use_kiro_cli: false (KiroSignInSources.tsx:214).

[DESIGN-REVIEWED] 32fc5d4

Description read

[DESCRIPTION-READ] 3787f4d24886c2ce2261d5d633ca9915394882d6a8fca1940119db9bc06373f6

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 32fc5d4e4d5a91a9404c2feb975fc3af26c4e1f0 — this comment is updated in place on each push.

Review details

No findings. The candidate list was empty. I read the whole diff and found nothing that meets the bar for a finding.

[OPUS-REVIEWED] 32fc5d4

Verdict parsed from the review's SHA-scoped output markers for commit 32fc5d4e4d5a91a9404c2feb975fc3af26c4e1f0.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 32fc5d4e4d5a91a9404c2feb975fc3af26c4e1f0 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 32fc5d4e4d5a91a9404c2feb975fc3af26c4e1f0 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 32fc5d4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 32fc5d4e4d5a91a9404c2feb975fc3af26c4e1f0 false-positive: <reason, 20 to 500 characters>

The sign-in card offered "Use the Kiro CLI account" to any dashboard
viewer, but the sign-out it runs is owner-only, so anyone else got a
403. can_use_kiro_cli now requires the owner.

Also states in same_account's docstring, and pins with a test, that
equal Identity Center or External IdP profile ARNs count as one
account: the cost is a missing two-accounts notice, never a wrong one.

Follow-up to #36324 review notes.
@buluoray
buluoray force-pushed the crew/slack/kas-sources-owner-check branch from bfcf1d5 to 32fc5d4 Compare November 14, 2026 17:38
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 4% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The PR adds the owner term to can_use_kiro_cli. It uses the same is_owner_dashboard_request check that _require_owner uses to guard POST /api/kas-login/logout, so the switch is offered only to someone who can run its sign-out. The frontend reads can_use_kiro_cli only to show or hide the button and its confirm step, and every other response field is unchanged. The new non-owner test uses stored state that would give True without the change, so it would fail if the change were removed. The same_account change is a docstring plus a test that pins what the code already does. The spec doc matches the code. Nothing blocks the merge.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 32fc5d4e4d · 27 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 14, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on this head: can_use_kiro_cli now starts with the owner value from is_owner_dashboard_request, the same predicate _require_owner uses to guard the sign-out route. The new test test_only_the_owner_is_offered_the_kiro_cli_account passes at this head. It fails with assert True is False when the owner and term is removed. The other tests in test_kas_login_sources.py pass either way. The spec kas-auth.md is updated in the same commit, and the frontend already hides the button and confirm step when the field is false.

Security: this only narrows what the dashboard offers. A falsy owner gives False, so the check fails closed. The sign-out route still enforces its own owner check and returns 403 to anyone else. Nothing that main refuses is now allowed.

Done well: the offer and its enforcement now come from one predicate, so they cannot drift apart. The test keeps the stored accounts of the owner case and changes only owner=False.

Optional:

  • The Proof line names head bfcf1d5. The patch is identical to 32fc5d4 (rebased only), so you could refresh it on the next body edit.
  • The claim that LTS skips the account-lock read for a non-owner is true in the code but has no test. An LTS non-owner case that spies on account_lock_allows would pin it.
  • The two new kind pairs in test_equal_organization_profile_arns_count_as_one_account could go into the existing test_the_verdict parametrize list.

@buluoray
buluoray merged commit aa9caab into main Nov 14, 2026
99 checks passed
@buluoray
buluoray deleted the crew/slack/kas-sources-owner-check branch November 14, 2026 19:30
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants