Repository navigation
feat(auth): reuse an in-date oidc client registration on sign-in - #35700
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: reusing the stored registration within a week's margin, with one fallback to a new registration when the stored client is refused, matches the stated goal and takes nothing away. Notes
[DESIGN-REVIEWED] f1e9f58 Description read[DESCRIPTION-READ] 9ec0717a0f6e328ad99cfcc738a71c3bc0d46779f1ce293be2bf57dfb95554bf 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 Nothing blocks. Each item traces to #24640 or the client churn the description names, and the retry on a refused stored client stops the reuse from blocking sign-in. Not checked: whether AWS's What this change shipsInventory (6 items) — 5 justifiedIntent: an Identity Center or Builder ID user stops creating a new SSO-OIDC client every time they sign in. This is an ADDITION (closes #24640).
[FIRST-PRINCIPLES-REVIEWED] f1e9f58 Description read[DESCRIPTION-READ] dee2c3b0a4335d8a339909444afb5891fa028ae013dff01f8c7ded5ef635b558 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: |
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: |
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. Reuse of a stored SSO-OIDC client is limited to the same slot and region, both client credentials present, and a recorded expiry more than a week away. Any non-start-URL BuilderIdAuthError from StartDeviceAuthorization falls back to one new registration and a restart, while StartUrlRejectedError is re-raised unchanged. The approved token carries the client that was actually used, along with its expiry. Other readers are unaffected: refresh keeps the client fields, doctor only reads the expiry, and the identity fingerprint includes client_id, but every completed sign-in bumps the sign-in generation, so account changes are still detected. Sign-out deletes the slot entry, so the next sign-in registers anew. 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 |
5f19fae to
1d6cd3f
Compare
|
Rebased: main moved in src/kiro_crew/auth/login/builder_id.py, src/kiro_crew/auth/service.py, test/test_kas_login_service.py and docs/system-specs/modules/kas-auth.md since this head's CI ran (ee7a026 -> 9ef0fc4); CI re-running. The four Backend Tests reds on the previous head ( Main also grew [operator: bolichen97] |
Every Builder ID and IAM Identity Center sign-in registered a new SSO-OIDC client, even when the slot's stored sign-in carried one that was good for weeks. kiro-cli keeps its registration and reuses it until it lapses. A sign-in now reuses the registration its own slot's stored token carries when it is from the same region and its recorded expiry is more than a week away. Otherwise, or when StartDeviceAuthorization answers the stored client with an error, it registers a new one as before. Closes #24640
1d6cd3f to
f1e9f58
Compare
|
Rebased: main moved in src/kiro_crew/crew_log/eager.py, src/kiro_crew/dashboard/handlers/sessions_parts/slot_teardown.py and docs/system-specs/modules/ since this head's CI ran (9ef0fc4 -> e97c8ee); CI re-running. The one Backend Tests red on the previous head ( The patch itself is unchanged (identical range-diff); none of this PR's four files changed on main between those two bases. New head: f1e9f58. [operator: bolichen97] |
buluoray
left a comment
There was a problem hiding this comment.
Approve on f1e9f58. A sign-in now reuses the client registration that its own slot already stores, but only when the registration is from the same region, has both client credentials, and has a recorded expiry more than a week away. Anything else registers a new client, as main does. When the auth service refuses the reused client at the start of the device flow, the sign-in registers one new client and starts over, so a refused registration cannot lock a person out. A refused start URL keeps its own error. The registration's scopes are not recorded, so a future change to the requested scopes must also stop this reuse; today that rule lives only in the spec text, while kiro-cli checks the scopes in code. No secret is written or logged in a new place: the reused credentials come from the same vault entry and go only to the same auth endpoint. One backend test shard first failed on this head on a timing test in a file this PR does not touch; it passed on one rerun, and every check on this head is now green. Decisive lines: src/kiro_crew/auth/login/builder_id.py:158-173, src/kiro_crew/auth/service.py:430-446, test/test_kas_login_oidc_reuse.py:48-118
Problem / Motivation
Goal: A Builder ID or IAM Identity Center sign-in reuses the client registration its slot's stored sign-in already carries while that registration is in date, and registers a new client only when there is none it can safely use.
Every Builder ID and Identity Center sign-in calls
RegisterClientand gets a brand-new SSO-OIDC client, even when the sign-in stored in the same slot carries one that is good for weeks. kiro-cli keeps its registration and reuses it until it lapses. #31630 stored the registration's expiry (client_secret_expires_at) and left reuse open on this issue.Why it matters
An Identity Center user whose session ends every working day registers a new client each morning, and AWS keeps each one for about 90 days. Reusing the stored registration ends that churn and matches kiro-cli, while the expiry check keeps a sign-in from ever starting on a registration that has lapsed or is about to.
Not a goal
KasToken.refresh_blocker, or whatkirocrew doctorand the dashboard sign-in card say about a lapsed registration.What changed (motivation → approach → change)
Crew registered a new client on every sign-in because
_begin_oidcinauth/service.pynever looked at the vault: it calledRegisterClientunconditionally.It now reads the slot's stored token first, and
stored_clientinauth/login/builder_id.pydecides whether that token's registration can carry the new sign-in: same region, and a recorded expiry more than a week away (REUSE_MARGIN_SECS). The week is there because the approved token keeps the reused client and its expiry, and AWS refuses every refresh after that date: a registration in its last week would cut short the sign-in it starts, so it is replaced instead. Otherwise a new client is registered, as before.If
StartDeviceAuthorizationanswers the stored client with any error, the sign-in registers a new one and starts over once, so a registration AWS refuses cannot lock anyone out of signing in. The one exception is a refused start URL (StartUrlRejectedError): it is not a client problem and keeps its own error. The kas-auth spec states the rule beside the SSO-OIDC flow.StartDeviceAuthorizationerror but a start-URL refusalBackwards compatibility
Compatible: nothing new is asked of a stored entry. One with no recorded expiry (written before #31630), from another region or without client credentials registers a new client exactly as today, and the approved token has the same shape either way.
Removes nothing: no key, field, path or behaviour goes away; a sign-in only skips a
RegisterClientcall it does not need.Tests
test/test_kas_login_oidc_reuse.py::test_a_sign_in_reuses_the_slots_registration_while_it_is_in_date(Builder ID and Identity Center): an in-date stored registration from the same region becomes the pending login's client, andRegisterClientis never called.test/test_kas_login_oidc_reuse.py::test_a_sign_in_registers_a_new_client_when_the_stored_one_cannot_serve: a lapsed registration, one two days from lapsing, one with no recorded expiry and one from another region each get a new client.test/test_kas_login_oidc_reuse.py::test_a_refused_stored_registration_is_replaced_but_a_refused_start_url_is_not: a refused stored client is replaced by exactly one new registration; a refused start URL raisesStartUrlRejectedErrorand registers nothing.Proof: PROVEN test/test_kas_login_oidc_reuse.py::test_a_sign_in_reuses_the_slots_registration_while_it_is_in_date[builder_id-builder_id-kwargs0], test/test_kas_login_oidc_reuse.py::test_a_sign_in_reuses_the_slots_registration_while_it_is_in_date[idc-identity_center-kwargs1], test/test_kas_login_oidc_reuse.py::test_a_refused_stored_registration_is_replaced_but_a_refused_start_url_is_not (head f1e9f58)
The four
registers_a_new_clientcases pass with the fix reverted too: before the fix every sign-in registered, so they pin the cases that must keep doing so.Determinism: the seven cases of
test_kas_login_oidc_reuse.pypassed 20 runs at-n0and 10 at-n 4 --dist loadgroupbesidetest_kas_login_service.pyandtest_kas_login_signout_generation.py; those seven and the 80 tests oftest_kas_login_service.pypassed in a shuffled order (seed 6163). They read no clock race: each stored expiry is days away from the margin it is checked against.Manual verification
N/A — unit coverage sufficient: the change is one decision before the two SSO-OIDC calls, and the tests fake those calls at the same seams the existing sign-in tests use. No live AWS sign-in was run.
Screenshots / video
N/A — no frontend file changes and nothing on screen changes.
Related Issues
Closes #24640
Follows #31630, which stored the registration expiry.
Sibling sweep
Swept: git grep -n "register_client(" -- src/
Siblings: none --
_begin_oidcis the only caller ofregister_client, so it is the only place a sign-in registers a client.Pattern harvest
Not generalizable: the missing reuse was a decision this one call site never made, not a code pattern a rule could catch.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement