Skip to content

feat: close the enterprise gate until a kiro login is seen - #23697

Merged
iamwhatever merged 2 commits into
mainfrom
feat/ee-login-gate
Oct 25, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
feat/ee-login-gate

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: In an enterprise build, Crew serves nothing but its login screen until a valid kiro login is seen, and locks again when that login expires or is lost.

The Crew Enterprise Edition RFC (docs/request-for-change/rfc-crew-enterprise-edition.md, section "Enterprise gate", #23208) requires that login and governance form one gate, and that while the gate is closed the gateway denies every API except login. kiro_crew.edition.is_enterprise() landed in #23213, but nothing reads it at the gateway yet: an enterprise build with no kiro login serves every route.

Why it matters

The enterprise edition is defended by that gate. Without it, an enterprise install with no login (or an expired one) exposes chat, config, sessions and every other API, which is the exact state the RFC's fail-closed rule forbids. This is the login half of Migration plan phase 2; the governance half needs a gate object to close, which this PR provides.

Not a goal

  • Governance rules fetch, policy URL, evaluator / deny-unnamed, and local loosening (other RFC items). The gate exposes close(reason) / clear(reason) for the governance item; this PR does not wire it.
  • Making the gateway exit on no login. The gate stays up CLOSED so the user can see the login screen and sign in.
  • Frontend changes. The existing setup gate reads GET /api/kiro-prerequisite, which stays open; screens that also call other APIs see a 403 until login.
  • Non-HTTP entry points (Slack and other channels, cron). They do not go through the gateway middleware.
  • Any change to an oss build.

What changed (motivation → approach → change)

RFC "Enterprise gate" → one small gate object, the existing login check, one allowlisting middleware:

  • src/kiro_crew/enterprise_gate.py (new): EnterpriseGate, open or closed while any reason holds it. close(reason) / clear(reason) / status() (open plus reasons) / add_listener. Each concern clears only its own reason, so a later governance failure cannot be cleared by a login. LoginWatch owns login_required: check() asks KiroPrerequisiteService.login_verified and opens or closes; sync() reads the latched verdict per request and only ever closes. It checks at once on startup, then every 5 s while closed, every 60 s while open; a close wakes it from the open interval.
  • src/kiro_crew/kiro_prerequisite_service.py: authenticated (latch read) and login_verified(max_age_secs). The latter reuses the setup gate's own whoami probe (_probe); it re-probes when the last probe is past its age or the identity store now names another account, and answers False when the probe raises. No second login check.
  • src/kiro_crew/dashboard/enterprise_gate_middleware.py (new): install_enterprise_gate (both entrypoints, right after the service is built; starts CLOSED; no-op in oss) and the middleware. While closed it serves only ALLOWED_WHILE_CLOSED, method-scoped; answers a SPA document navigation with the static shell (never the route's handler); and raises 403 enterprise_gate_closed with the reason for everything else, including unknown routes and every WebSocket upgrade. When the gate closes, every connection that carried a gated request while open is closed, tracked per connection until it closes so a download aiohttp sends after the handler returns is cut too.
  • src/kiro_crew/dashboard/handlers/kiro_prerequisite.py: while the gate is closed, the status reports enterprise_login_required: true and initial_setup_complete: false, so the existing setup gate shows its sign-in screen instead of rendering the app for an established install. Nothing changes in oss.
  • website/src/components/KiroPrerequisiteGate.tsx: when the status carries enterprise_login_required and the app has not been shown yet (first boot, or a reload), the gate skips every bypass that would render the app (ready, an established install, a usable independent harness, the pending-config shortcut), so its existing first-run screens run in order: a missing CLI or a sandbox refusal keeps its own remedy, then the sign-in step. The poll stays at 5 s even when ready is latched; the config and harness reads, which the closed gate refuses, are not issued, and the other-agents picker (it writes config) is hidden. A relock of a dashboard already in use keeps the app mounted and on screen; the gateway refuses its requests until sign-in, and a reload lands on the sign-in step. The relock screen is follow-up Enterprise edition: show a sign-in screen when the login gate relocks a running dashboard #23882. No new string. The flag is absent on oss, so nothing changes there.
  • src/kiro_crew/mcp_shared_policy.py, mcp_shared_dispatch.py: a managed MCP server whose tool-policy read gets the gate's 403 (enterprise_gate_closed) records gateway_locked, which refuses the call, instead of reading it as the permissive policy_forbidden. Without this, a turn started from cron or a channel while the gate is closed would run with the operator's managedToolPolicy exclusions dropped.
  • src/kiro_crew/dashboard/server_runtime/middleware_chain.py: _insert_enterprise_gate puts the middleware right after token auth in both chains. Inner to token auth, so it only narrows; it raises, so deny_audit records each refusal. Enterprise boot with no gate installed raises instead of serving ungated. The middleware holds the gate object, so the tunnel's copied chain shares it.

Allowlist while closed (ALLOWED_WHILE_CLOSED):

Route Methods Why
/api/kiro-prerequisite GET login status and sign-in command
/api/kiro-prerequisite/repair-specs, /api/kiro-prerequisite/update-cli POST the setup screen's two owner-only remedies (agent specs, too-old CLI)
/api/auth/me, /api/auth/refresh GET, POST dashboard session cookie for the call above
/api/auth/logout, /api/logout POST session revocation stays possible while closed
/api/token/local GET local token mint (loopback + local secret) the desktop app opens with
/api/health, /api/live, /api/ready GET supervisor probes; no user data
/api/shutdown POST stop a closed gateway (loopback + local secret)
/, /api/theme/boot, /logo.png, /favicon.ico, /manifest.json, /sw.js, /icon-N.png, /assets/*, /fonts/* GET the login screen's static files

How routes were enumerated: test_closed_gate_serves_exactly_the_pinned_routes builds an app with kiro_crew.dashboard.routes.register_all (the dashboard route registry) plus server._register_mcp_routes, walks app.router.routes(), and pins the exact set of registered (method, route) pairs the closed gate serves. test_every_allowlisted_api_path_is_a_real_route fails if an allowlist entry stops matching a registered route.

Security: no bind, origin, CORS or token-auth rule changes; the change only removes access in an enterprise build.

Backwards compatibility

Compatible: an oss build installs no gate and no middleware (test_oss_installs_no_gate_and_no_middleware, test_oss_chain_insert_is_a_no_op); the two new service members are additive.

Removes nothing: in oss nothing is gated, and the enterprise edition has no installed base.

Tests

test/test_enterprise_gate.py (new):

  • Gate state: starts closed; opens only when every reason is cleared; refuses malformed reasons; listener isolation.
  • Login watch: check opens on login and closes on expiry; a raising probe closes; sync closes but never opens; the run loop's intervals.
  • login_verified: probes when never probed, re-probes on an identity change, fails closed on a raising probe.
  • Middleware over a real aiohttp server: closed gate denies /api/status and allows /api/kiro-prerequisite; unknown routes denied; WebSocket upgrade denied (403); a page navigation gets only the static shell; login opens, expiry closes (latch and background check), re-login reopens; closing drops an open WebSocket and a connection whose handler already returned; logout routes stay open; the status asks an established install to sign in (owner and non-owner).
  • oss unchanged; enterprise without an installed gate refuses to build; chain placement right after token auth.
  • Route enumeration as above.

website/src/test/KiroPrerequisiteGate.enterprise.test.tsx (new): the flag blocks and keeps the 5 s poll even with ready; on first boot an established install and a latched ready get the sign-in step, a non-owner the owner screen, never the dashboard; a missing CLI keeps the install remedy and a sandbox refusal its remedy; a usable independent harness does not bypass and the refused reads are skipped; the dashboard opens once the gate reports open; a relock of an app already shown keeps it mounted with its draft. test_a_close_wakes_a_watch_sleeping_its_open_interval covers the wake; test_403_from_a_closed_enterprise_gate_refuses_the_call (in test_mcp_shared_cache.py) the policy read.

Updated pins: test_kiro_prerequisite_service.py (member table), test_dashboard_server_composition_contract.py (lazy imports), test_dashboard_server_composition_contract_reach.py (boot call order).

Local: black/isort/flake8/mypy clean, file-line-cap, comment-history, brand, docs-lint pass. scripts/local-gate.py backend related set: all pass except 84 failures in test_kas_bundle.py, test_file_explorer_app.py, test_design_tweak_backend.py, test_design_tweak_devproc.py, test_app_agent_launch_copy.py, which fail identically on a clean origin/main checkout on this host (old glibc / host sandbox).

Manual verification

N/A — unit and aiohttp-server tests cover the gate, the middleware and the chain wiring; there is no enterprise build to run end to end until the governance half lands.

Screenshots / video

Rendered from this head through the isolated capture entry, with /api/kiro-prerequisite answered from fixtures and every other /api/ call answered 403 enterprise_gate_closed: the first-boot sign-in step with the gate closed, and the other-agents picker hidden.

first-run sign-in dark
first-run sign-in light

A relock of a dashboard that is already open changes nothing on screen in this PR (see below), so it has no capture.

Related Issues

Refs #23882 (relock screen for a running dashboard). Refs #23206. RFC: #23208. Builds on #23213.

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; see the Licensing section of CONTRIBUTING.md.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

No new strings or controls. Both screenshots show the sign-in step that enterprise mode reuses, and the blind reader read "Check sign-in again" correctly. The only control this PR changes is the other-agents picker, which it hides.

Notes

[UX-REVIEWED] d678afc

Description read

[DESCRIPTION-READ] 424f7c442d88f1c107e7ff59e1a4549b83e313520f5c736fbef53743f6a487fd

That sha256 names everything this verdict read: the PR description, plus the 5 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 added the readiness: checking Automated validation is still running label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of d678afc4f9faee03aa317fc45a8dc43633160224 — 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

No item is blocking. Two framing gaps should be read before merge: the PR goes against the accepted RFC's "exit on no login", and its own Not a goal excludes frontend changes that the diff ships.

Notes

  • Item 1 — inherited: the accepted RFC says "Start | Login and fetch rules. If either fails, exit" and "No login, no Crew: it exits". Not a goal turns that down ("The gate stays up CLOSED so the user can see the login screen"), and no recorded decision covers staying up closed at boot. Subtraction: none in code; this needs a maintainer to rule on the RFC's start row.
  • Item 5 — oversized: Not a goal lists "Frontend changes", yet the diff adds appShown/unlessRelocked and an enterpriseLocked bypass at seven sites in KiroPrerequisiteGate.tsx. Subtraction: drop the relock-preservation machinery (appShown, unlessRelocked) and leave relock to Enterprise edition: show a sign-in screen when the login gate relocks a running dashboard #23882. Clears when: the mechanism is removed, or a human amends the Goal.
  • Item 1 — one consumer, generalized: EnterpriseGate(closed_for=...) is only ever given REASON_LOGIN_REQUIRED in production (the default is used at 1 site in install_enterprise_gate). Subtraction: drop the closed_for parameter and start closed for login unconditionally.

What this change ships

Inventory (8 items) — 5 justified

Intent: an enterprise build serves only sign-in until a kiro login is verified, and relocks when that login is lost. ADDITION.

  1. Enterprise gateway boots closed and stays up instead of exiting — inherited (diverges from the RFC's start row)
  2. Every non-allowlisted route and WebSocket gets 403 enterprise_gate_closed while closed — justified
  3. Open connections are cut when the gate closes — justified
  4. Background login re-check every 5 s closed / 60 s open, plus a per-request latch close — justified
  5. The setup screen shows sign-in for an established install; a relock keeps the app mounted — oversized (Not a goal: frontend)
  6. --test-mode no longer assumes readiness in enterprise builds — justified
  7. Managed MCP tool calls are refused (gateway_locked) while the gate is closed — justified
  8. Status payload gains enterprise_login_required — undeclared in Goal; consumed by item 5

[FIRST-PRINCIPLES-REVIEWED] d678afc

Description read

[DESCRIPTION-READ] aa2eb6a39491a68f3330a3961c1f71183fcbdb8a99774a5332de075d2097ea90

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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The gate only exists in enterprise builds, which have no installed base yet. It only narrows access, and a revert would undo it cleanly.

Notes

  • kiro_prerequisite_service.py now ignores assume_ready in enterprise builds (self._assume_ready = assume_ready and not is_enterprise()). As a result, a gateway started with --test-mode in an enterprise build stays locked without a kiro login. The visible part of the description doesn't mention this. Either state it there or confirm that no enterprise E2E or CI lane relies on test mode to get past the gate.

[DESIGN-REVIEWED] d678afc

Description read

[DESCRIPTION-READ] ef5e6b5c012fe953910f66753b4f1e435553415c16377ccb84c65f77ab274782

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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

Notes:

  • _probe's timed-out branch leaves _probe_identity unset. On a signed-in host whose probe keeps timing out, login_verified re-probes on every 5 s watch tick instead of waiting out the 60 s max_age. The only cost is extra spawns; the gate still answers correctly.

[OPUS-REVIEWED] d678afc

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

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

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] d678afc

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

@iamwhatever

Copy link
Copy Markdown
Contributor Author

GPT F1 (established installs bypass the login screen): real, fixed in 9d88bbe. While the gate is closed, GET /api/kiro-prerequisite now reports enterprise_login_required: true and initial_setup_complete: false (owner and non-owner payloads), so KiroPrerequisiteGate no longer takes the established-install bail-out and shows its sign-in screen. The on-disk setup marker is untouched, and an oss build never sets either key. Test: test_closed_gate_status_asks_an_established_install_to_sign_in.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

GPT F2 (file downloads escape gate-close revocation): real, fixed in 9d88bbe. Admission is now tracked per connection and held until the transport itself closes, instead of being dropped when the handler returns, so a FileResponse that aiohttp sends after the middleware returns is cut when the gate closes. Test: test_closing_the_gate_drops_a_connection_after_its_handler_returned.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

GPT F3 (closed gate prevents session revocation): real, fixed in 9d88bbe. POST /api/auth/logout is allowlisted while closed, and so is the CLI twin POST /api/logout (loopback + local secret), the other session-revocation route. Both handlers keep their own origin and credential checks. Test: test_closed_gate_allows_session_revocation; the route-walk pin now lists both.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

First Principles note, item 3 (login_verified duplicates verified_ready): kept. verified_ready answers ready, which also needs the agent specs on disk and acp support; the gate is about login only, and closing it over a missing spec would lock out the owner from the repair route. verified_ready also has no identity-change re-probe, which is what reopens the gate within seconds of a fresh kiro-cli login. Both share the same _probe, so there is still one login check.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

First Principles note, item 6 (multi-reason gate with one consumer): kept on purpose. The work item asked for a gate-state object with a clear API the governance item will close under its own reason. With a single flag, a login success would reopen a gate that a governance fetch failure closed, which is the fail-open case the RFC forbids. The reasons set is about 20 lines.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Design note 1 (setup gate also calls config and /api/acp-backends, which 403 while closed): accepted as-is for this PR. Both return host config data, so allowlisting them would widen what a closed gate serves. With F1 fixed the sign-in card does show; the extra error line is cosmetic until an enterprise-aware login screen lands. Frontend is out of this PR's goal.

@iamwhatever

iamwhatever commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Design note 2 (a slow whoami probe closes the gate and drops live chats): this is the RFC's fail-closed rule ("Any failed step denies"), so a probe that cannot confirm the login closes the gate. While closed, the watch checks every 5 s and re-probes once the last probe is 60 s old (sooner if the identity store changes, or when the sign-in screen's own poll probes), so a transient timeout reopens within about a minute. Whether a probe timeout should count as signed out is a policy question for the governance half; changing it here would loosen the gate.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 24, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

GPT (test mode bypasses enterprise login verification): real, fixed in 1d4bd30. KiroPrerequisiteService.__init__ now drops assume_ready in an enterprise build, so --test-mode starts with authenticated=False and login_verified runs the real probe; both entrypoints build the service through that one constructor. oss test mode is unchanged. Tests: test_test_mode_does_not_assume_a_login_in_an_enterprise_build, test_enterprise_test_mode_login_check_still_probes, test_test_mode_still_assumes_a_login_in_oss.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 24, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

GPT (make the enterprise login override independent-harness readiness): real, and the same class as the earlier F1, so the approach changed from a backend-only payload tweak to the gate itself. Fixed in 73154ab: KiroPrerequisiteGate checks enterprise_login_required before every bypass (ready, established install, a usable independent harness) and renders a sign-in card; otherBackendReady is false while the flag is set, and the config and harness reads are not issued. Tests: website/src/test/KiroPrerequisiteGate.enterprise.test.tsx.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 24, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 24, 2026
buluoray
buluoray previously approved these changes Oct 24, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review of the changes since my approval at 83d9784, pinned to head b1cb28c69eddae88def8ef60d243f5ac788b5c54 (merge-base 56b568a is unchanged, so git range-diff isolates the new commit).

What changed: lib/closeAllDialogs.ts (one window event), the Radix Dialog root and Modal both honour it, and a LockCover that sends it on mount, traps Tab (handleEscape:false, restoreFocus:false), pulls stray focusin back, and refocuses after the closing dialogs' own restore timers have run.

Verified:

  • Escape cannot dismiss the cover. It is derived from the prerequisite status alone, and the trap's Escape handler is a no-op.
  • Both timers are cleared and the focusin listener is removed on unmount.
  • No new user-facing strings.
  • The cover is fixed inset-0 z-[10002] pointer-events-auto, so it stays clickable even when a Radix dialog leaves body at pointer-events:none.
  • KiroPrerequisiteGate.enterprise.test.tsx passes 11/11. The Modal, Dialog and gate suites pass 238/238. tsc -p tsconfig.app.json --noEmit is clean.
  • Mutations, run one at a time:
    • Removing requestCloseAllDialogs() turns both closes an open radix|modal dialog on relock… cases red.
    • Removing the focusin pull-back turns both red (radix at the pull-back assertion, modal at the initial focus assertion).
    • Flipping handleEscape to true is an equivalent mutant (the callback is a no-op). No test presses Escape on the cover.

Follow-ups (non-blocking, reproduced in jsdom):

  1. A controlled Radix dialog whose owner declines onOpenChange(false) stays open under the cover, and its focus scope keeps keyboard focus on the hidden dialog. Examples: useCrewEditor.requestClose while committing or capabilityBusy, or SchedulePage while a delete is running. Pointer users and the 5 s poll are unaffected, but keyboard users cannot reach "Check sign-in again".

  2. A Radix dialog that opens after the cover is up fights the cover's focusin pull-back until the stack overflows. A plausible path is a discard prompt raised once a pending save settles.

  3. The cover has no role="dialog" or aria-modal, and the app under it is not inert, so a screen reader's virtual cursor can still reach it.

    Making everything except the cover inert while relocked (including dialog portals), plus a re-entrancy guard on the pull-back, would close all three. It might also let dialogs be suspended instead of dismissed.

Lane dispositions on this head:

  • GPT 6.1 (fenced BLOCK, dialog draft dropped on relock): the finding is real, and it is the trade-off stated as a residual in the description. The adjudication notes the loss is narrower than on main, where a relock unmounted the whole app. This needs an explicit owner decision before the gate can clear.
  • First Principles (BLOCK): the ## Not a goal bullet "Frontend changes" is no longer true, and "What changed" does not list closeAllDialogs.ts, the Dialog root change, or the Modal close-all path. Please amend the description so it matches the diff, and add a "What changed" bullet for the dialog close-all mechanism, including that it overrides dismissDisabled.
  • Bundle Size Gate: ModelEffortDropdown is at 505.0 KB against a 500 KB budget. It passed at 83d9784, and main has gained frontend code since then. Please rebase and re-run. If it is still over, split the chunk or justify a budget change in the PR.

Approving the code in this increment.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

GPT (enterprise relock destroys unsaved dialog drafts, Modal.tsx:92) and First Principles (out-of-goal relock cover and close-all mechanism): resolved in b9b4d3a by removing the mechanism. LockCover, website/src/lib/closeAllDialogs.ts and its hooks in Modal.tsx and components/ui/dialog.tsx are gone; both dialog files are back to main. A relock of a dashboard already in use no longer replaces, covers or closes anything: the app stays mounted and on screen, and the gateway refuses its requests (403 enterprise_gate_closed) until sign-in. So no page or dialog draft is dropped. A reload lands on the sign-in step, which is unchanged. The relock screen is now follow-up #23882, which records the draft, dialog and copy issues found here. Test: keeps the app mounted and on screen when an established session relocks.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 25, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving at b9b4d3ac72e62b188347f0618b94e7ee71dff227.

This increment. The relock cover, the close-all-dialogs mechanism and the Modal/dialog hooks are gone. When a dashboard already in use relocks, it now stays mounted (unlessRelocked / appShown in KiroPrerequisiteGate.tsx). Before a resolved status has rendered the app, a lock still shows the first-run sign-in path. Both lane findings from b1cb28c69e are moot as a result (GPT: dialog drafts dropped; First Principles: frontend scope), and every AI review lane on this head reports no blocking findings.

Leaving the app on screen is safe because the server enforces the gate.

  • The gate middleware sits right after token auth in both chains: _insert_enterprise_gate in _install_dashboard_middlewares and in _install_api_middlewares.
  • It is an allowlist. While closed, every route not on it is refused 403 enterprise_gate_closed, including unknown routes and every WebSocket upgrade.
  • When the gate closes, connections that carried a gated request are closed.
  • The TCP, secondary-loopback and unix-socket sites share the one runner, so they all pass through it. The tunnel copies the middleware list after the gate is inserted.
  • The middlewares that run before it only refuse, redirect, or serve the static shell.
  • test_closed_gate_serves_exactly_the_pinned_routes walks the real dashboard and MCP route tables and pins the 16 that stay open.

Verification.

  • test/test_enterprise_gate.py and the related backend files passed (184 tests). KiroPrerequisiteGate.enterprise and KiroPrerequisiteGate passed (71 tests). The full suite was not run locally.
  • Reverting the relock branch (relocked = false && …) turns keeps the app mounted and on screen when an established session relocks red.
  • Admitting the app from an unresolved status turns 6 enterprise tests red.
  • Letting closed-gate requests through to their handler turns 4 tests in test_enterprise_gate.py red.
  • Dropping the WebSocket-upgrade exclusion from the allowed-route check stays green. It is covered in effect by test_no_websocket_route_is_allowlisted, since no allowed path is a WebSocket route, so it is defence in depth rather than independently tested.

Bundle Size Gate. The red check (ModelEffortDropdown 506.7 KB against 500 KB) also fails on main (#23866). This PR adds about 1.7 KB to that chunk, which still fits under the 531 KB ceiling proposed in #23867. It needs #23867, or an equivalent fix, before it can merge.

Non-blocking follow-ups:

  1. Until #23882 lands, a relocked dashboard has no banner and nothing that says to sign in. Actions fail with the 403 message, live views stop updating, and only the status poll reopening the gate after a new sign-in, or a reload, recovers it. Please give #23882 a tier label so it is triaged.
  2. app() sets appShown.current during render. That works here, but moving the write into an effect would keep it correct under concurrent rendering.
  3. Builtin apps that run their own HTTP servers were not part of this check. If any of them can be reached directly rather than through gateway routes, it would need its own gate.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 25, 2026
Joe Guo added 2 commits October 25, 2026 01:19
An enterprise build now starts with the gateway gate closed and opens it
once the setup gate's own whoami probe sees a valid kiro login. While
closed, middleware placed right after token auth in both gateway chains
serves only the login status route, the session-cookie routes, the
liveness probes, local shutdown and the login screen's static files;
every other route, an unknown one or a WebSocket upgrade included, is
refused 403 enterprise_gate_closed. A lost or expired login closes the
gate again, and connections admitted while open are dropped. An oss
build installs nothing.

The gate keeps a set of reasons so a later governance fetch failure can
close it under its own reason without touching the login half.

Design: docs/request-for-change/rfc-crew-enterprise-edition.md,
"Enterprise gate".
Replacing the app with the setup screen on relock unmounted it and lost
form state held in components. Once the app has been admitted from a
resolved status, a relock now leaves it mounted and on screen; the
gateway refuses its requests until sign-in, and a reload lands on the
sign-in step. The relock screen itself is follow-up #23882.
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 25, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-approve @ d678afc: pure rebase, range-diff against b9b4d3a is identical (2 = 2 commits, 0 interdiff lines).

@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 Oct 25, 2026
@iamwhatever
iamwhatever merged commit bb642b4 into main Oct 25, 2026
109 checks passed
@iamwhatever
iamwhatever deleted the feat/ee-login-gate branch October 25, 2026 06:35
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 25, 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.

3 participants