Skip to content

The console signs in through the sign-in proxy and shows who is signed in #716

Closed

Description

@V3RON

Part of #701.

Scope

Behind a sign-in proxy, the console opens with no token form and shows who is signed in. When the proxy's identity is refused, the token form says why. Sign out sends a proxy person to the proxy's sign-out page, or is not shown when there is none. A token-signed operator also sees their name (the token's label). Opened directly, without the proxy, the console works as today.

In short

The console now asks "who am I?" (GET /v1/identity) when it has no token. If the answer is a person from the proxy, it opens. The sidebar shows "Signed in as " for everyone.

flowchart LR
  L[Console loads] --> T{token stored?}
  T -->|yes| C1[as today, name from /v1/identity]
  T -->|no| W["Signing in… while GET /v1/identity runs (new)"]
  W -->|200, via proxy| C2[console opens, Signed in as name]
  W -->|401 with reason| F1
  W -->|anything else| F2
  F1[token form + refusal line]
  F2[token form, as today]
Loading

The refusal line, word for word: "Your sign-in proxy's identity was refused: . You can still sign in with an operator token." where is:

reason
expired it has expired
not-yet-valid it is not valid yet; check this machine's clock
wrong-issuer it comes from a different sign-in service than this daemon expects
wrong-audience it was made for a different application
unknown-key, bad-signature its signature does not check out
algorithm it is signed in a way this daemon does not accept
malformed it is not a valid sign-in token
keys-unavailable this daemon cannot reach the sign-in service's keys
any other value it was refused
Situation Today After
behind the proxy, signed in, no token stored token form console opens; sidebar "Signed in as Alice"
behind the proxy, JWT expired token form token form + "…it has expired. You can still sign in with an operator token."
behind the proxy, signOutUrl set — Sign out goes to that address
behind the proxy, no signOutUrl — no Sign out button
behind the proxy, operator token pasted console opens console opens as the token; "Signed in as "; Sign out forgets the token and the identity check opens the proxy session again
identity check still running at load token form at once a plain "Signing in…" page, no form
proxy session, a later request answers 401 — one identity check for all requests that got it: refused → token form with the line; nobody → token form
proxy session, the proxy's own session ended: requests get an answer that is not Simlock's (Cloudflare redirects to its login page, which fetch cannot follow; oauth2-proxy answers 403 with its HTML sign-in page) while /v1/healthz, let around the proxy, answers — the identity check gets the same not-Simlock answer, /v1/healthz answers, so the page reloads and the proxy shows its login page
the same, again within 60 s of that reload — no reload: "Your sign-in has ended." with a Sign in again button that reloads
proxy session, wifi drops (requests and /v1/healthz fail) — "Reconnecting", as today; no reload
token session, a request answers 401 (token revoked) signs out to the token form forgets the token, then the identity check: behind a working proxy, the proxy session opens; else the token form
no proxy, no token token form token form (the identity check answers 401 with no reason)
token session, token has no label — "Signed in as tok_…"

Collapsed sidebar: the line is hidden; the Sign out button's tooltip reads "Sign out (Alice)".

If this goes wrong, a user would notice the token form behind a working proxy, or a console that signs a person out in a loop.

Technical spec

Facts

Commit ccb50353.

# Fact Source
F1 The session holds only a token, in sessionStorage key simlock.operatorToken ui/src/data/session.ts:1-35
F2 Every request is fetch with credentials: "omit"; Authorization only when a token exists ui/src/data/api.ts:53-57
F3 Any 401 signs out ui/src/data/api.ts:126-127; ui/src/state/shell.ts:16-23
F4 App shows SignInScreen while the session has no token, else the shell ui/src/app/app.tsx:22-30
F5 The sign-in check probes /v1/healthz, then /v1/workers with the token; refusal strings at :40-49 ui/src/data/sign-in-check.ts:19-49
F6 The sidebar foot is the connection, Sign out, collapse ui/src/app/shell.tsx:49-79; docs/internal/DESIGN.md:134-138
F7 The live stream reads with fetch through the same API client ui/src/data/live/connection.ts:302; ui/src/data/live/sse.ts:1-2
F8 CSP connect-src 'self', form-action 'none' src/http/server.ts:20-33
F9 Console fixtures start a daemon on a free loopback port with its own config, mint tokens, and set baseURL e2e/console/fixtures.ts:72-87,123-137,156-168
F10 "the page makes no request to any host but the daemon" is pinned e2e/console/sign-in.spec.ts:146
F11 The browser lane runs Chromium, Firefox and WebKit playwright.config.ts (projects)
F12 Layers: screens → state → data → model; a screen never fetches ui/AGENTS.md "Layers"
F13 GET /v1/identity (#713), its via: "proxy", signOutUrl and the 401 reason (#714), the CSRF rule (#715) #701 Shared values
F14 Docs say "Sign out forgets the token at once" and the sign-in table docs/CONSOLE.md:100-132
F15 The console sends only reads; its API client has get, getJson, stream, healthz ui/src/data/api.ts:75-86
F16 main.tsx wires signOut: session.signOut into the API client ui/src/main.tsx:15
F17 A network error on a live resource is classified retry or lost, never sign-out ui/src/data/live/connection.ts:309-313
F18 "signing in with an empty field asks the daemon nothing" records every /v1/ request after page.goto("/") and expects none e2e/console/sign-in.spec.ts:42-56
F19 oauth2-proxy's alpha config can inject the session's ID token into a header we name (claimSource.claim: id_token), stripping a client-sent copy, and leave Authorization as the request sent it; its legacy --pass-authorization-header instead adds a second Authorization value beside the request's own, or strips the request's own oauth2-proxy v7.15.5 pkg/apis/sessions/session_state.go:143-147; pkg/middleware/headers.go:28-58,76; pkg/apis/options/legacy_options.go:254-260,380-383

Modules touched

Search: rg 'credentials|session\.token|signOut|SignInScreen|useTokenCheck' ui/src (adds ui/src/main.tsx).

flowchart LR
  A["app/app.tsx (changed)"] --> SI["screens/sign-in (changed)"]
  A --> SH["app/shell.tsx foot (changed)"]
  SI --> ST["state/sign-in.ts, shell.ts (changed)"]
  SH --> ST
  ST --> D["data: session.ts, api.ts, identity-check (new)"]
  D --> M["model: refusal text (new)"]
Loading
  • ui/src/data/session.ts: a session is a token, or a proxy identity { name, signOutUrl? }, or none, or checking, or ended (the "Your sign-in has ended" screen). The token still lives only in sessionStorage; a proxy identity lives in memory.
  • ui/src/main.tsx: wires the API client's 401 and not-Simlock-answer hooks to the session (F16).
  • ui/src/data/api.ts: credentials: "same-origin"; marks each failure as a 401, a not-Simlock answer (a network error, or a 401 or 403 whose body is not Simlock's { "error": { "code" … } }), or other. In a proxy session a 401 or a not-Simlock answer asks for the shared identity check instead of signing out; in a token session a 401 forgets the token and asks for it.
  • ui/src/data/identity-check.ts (new), the one place that decides what a failure in a proxy session means: GET /v1/identity with no token; outcomes proxy, refused(reason), none, and, for a not-Simlock answer, a GET /v1/healthz: it answers → ended, it fails → unreachable. One check runs at a time; callers while it runs get its outcome. At load, ended and unreachable count as none (the page itself came through the proxy).
  • ended → if sessionStorage key simlock.proxyReloadAt holds a time under 60 s ago, the "Your sign-in has ended." screen; else it stores now and reloads the page. unreachable → nothing changes; the live connection shows "Reconnecting" as today.
  • ui/src/data/live/connection.ts: in a proxy session its loss path asks the identity check first; proxy reconnects at once, unreachable enters today's /v1/healthz backoff (F17), the others end the session as above.
  • ui/src/model/: the reason → table.
  • ui/src/state/sign-in.ts, ui/src/state/shell.ts, ui/src/screens/sign-in.tsx, ui/src/app/app.tsx, ui/src/app/shell.tsx.
  • e2e/console/fixtures.ts (a proxy fixture; it passes the whole http block, since startDaemon spreads config at the top level, fixtures.ts:77-87), new e2e/console/proxy-sign-in.spec.ts, e2e/console/sign-in.spec.ts (F18's test records requests only after the load-time identity check has answered; the no-other-host test also expects the load-time 401 from /v1/identity among console errors, sign-in.spec.ts:150-156,174-176).
  • Docs: docs/CONSOLE.md ("Behind a sign-in proxy", the sign-in table, "Staying signed in"), docs/internal/DESIGN.md (the sidebar foot), ui/AGENTS.md.

Contract and event changes

none. The console reads GET /v1/identity (#713) and the 401 body's reason (#714); a reason it does not know shows "it was refused".

Other code on the same state

State: the console session. Search: rg 'session\.(token|signIn|signOut|subscribe)' ui/src: app.tsx, main.tsx, state/sign-in.ts, state/shell.ts; plus data/api.ts and data/live/connection.ts, which reach it through the hooks main.tsx wires.

  • The live connection reconnects when a stream ends (connection.ts:294-295); a follow stream ended at JWT expiry (Sign in through a sign-in proxy's signed JWT #714) is reconnected with the proxy's fresh JWT.
  • A token sign-in in a proxy session replaces the proxy identity; Sign out of the token, or a 401 on it, returns to the identity check, which opens the proxy session again behind a working proxy.
  • The live connection's own loss and /v1/healthz backoff (connection.ts:205-227,380-405) stays the one place for "Simlock is unreachable"; the identity check only adds "the proxy's session ended" before it, in a proxy session.

Failure modes

Call Outcome What happens Limit, counted from
GET /v1/identity at load 200 via: "proxy" console opens the API client's request timeout, as today
same 200 with another via token form, as none same
same 401 with reason token form + line same
same 401 without reason, or 403 token form same
same network error, timeout, 5xx token form; the sign-in check reports the daemon as today (F5) when the person tries a token same
a later request in a proxy session 401, from one or many requests at once one shared identity check; refused → form with line; none → form same
a later request in a proxy session not Simlock's answer; identity check not Simlock's; /v1/healthz answers reload, or the ended screen within 60 s of the last the API client's request timeout, per request
same not Simlock's answer; /v1/healthz fails "Reconnecting", as today today's backoff
a later request in a token session 401 forget the token; identity check as above
Sign out signOutUrl set the page goes to it none

State: the proxy identity is memory only; a reload checks again. simlock.proxyReloadAt in sessionStorage survives the reload; a tab whose storage is blocked never reloads and shows the ended screen.

Rules in play

  • ADR 0033 §7: the console's sign-in through the proxy, same-origin, Sign out.
  • ADR 0011 §6, as amended by ADR 0033: a stored token still goes only as Authorization: Bearer to /v1 on this origin.
  • Behind oauth2-proxy the CONSOLE.md example injects the ID token as X-Id-Token through the alpha config (F19), so a pasted token's Authorization reaches Simlock untouched.
  • ui/AGENTS.md: a screen never fetches; the refusal text is a model/ function with a unit test.
  • docs/internal/DESIGN.md voice: buttons are verbs ("Sign out").

Tests

Seam: the browser lane, with a proxy fixture in e2e/console/fixtures.ts: a node:http server on 127.0.0.1 that forwards every request to the fixture daemon, adds a JWT signed by a test key in the configured header, and serves the key set; the daemon's http.proxyAuth.jwksUrl points at it. The fixture can switch to an expired JWT (more than 60 s past, beyond #714's allowance), to answering every request but /v1/healthz with a 302 to another origin (Cloudflare's way), and to answering them with 403 and an HTML page (oauth2-proxy's way). Model on e2e/console/sign-in.spec.ts. Unit tests in ui/src/data and ui/src/model.

  • ui/src/model: each reason row of In short gives its ; an unknown reason gives "it was refused".
  • ui/src/data: the identity check answers proxy for a 200 via: "proxy", refused(reason) for a 401 with reason, none for a 200 with another via, a 401 without reason, a Simlock 403 and a 5xx; for a network error, an HTML 403 and an HTML 401 it asks /v1/healthz and answers ended when that answers, unreachable when it fails; it sends no Authorization and credentials: "same-origin".
  • ui/src/data: in a proxy session three requests answering 401 at once start one identity check, whose outcome becomes the session; in a token session a 401 forgets the token and starts the identity check.
  • ui/src/data: ended reloads and stores the time; ended again within 60 s shows the ended screen and does not reload; past 60 s it reloads again; with storage blocked it shows the ended screen; unreachable changes nothing.
  • e2e/console/proxy-sign-in.spec.ts: through the proxy fixture, the console opens on Overview with no token form, and the sidebar reads "Signed in as Alice"; collapsed, the Sign out tooltip reads "Sign out (Alice)".
  • e2e/console/proxy-sign-in.spec.ts: while the fixture holds the identity answer, the page shows "Signing in…" and no token form.
  • e2e/console/proxy-sign-in.spec.ts: with signOutUrl set to a fixture page, Sign out lands on it; without, there is no Sign out button.
  • e2e/console/proxy-sign-in.spec.ts: with the fixture sending an expired JWT, the token form shows "Your sign-in proxy's identity was refused: it has expired. You can still sign in with an operator token."; pasting a labelled operator token opens the console reading "Signed in as "; after the fixture goes back to a good JWT, that token's Sign out lands in the proxy session reading "Signed in as Alice".
  • e2e/console/proxy-sign-in.spec.ts: signed in through the proxy, when the fixture switches to an expired JWT, the next request takes the console to the token form with that line.
  • e2e/console/proxy-sign-in.spec.ts: signed in through the proxy, when the fixture switches to the 302 mode, the page reloads and lands on the other origin; in a fresh tab with the 403 HTML mode, it reloads and shows the fixture's HTML page; then, within 60 s, switching the fixture back to a good JWT, loading the console, and switching to the 403 HTML mode again shows "Your sign-in has ended." and Sign in again with no reload.
  • e2e/console/proxy-sign-in.spec.ts: signed in with a token behind the proxy, revoking that token takes the console to the proxy session ("Signed in as Alice").
  • e2e/console/sign-in.spec.ts: opened directly with a labelled operator token, the sidebar reads "Signed in as "; the other sign-in tests pass unchanged, and F18's test still sees no request after an empty submit.
  • e2e/console/proxy-sign-in.spec.ts: through the proxy, the page makes no request to any host but the proxy's (extends the check at sign-in.spec.ts:146).

Assumption: the 302 and the 403 HTML reload cases each start in a fresh browser tab (fresh sessionStorage), because the 60 s simlock.proxyReloadAt rule shows the ended screen on a second ending in the same tab; the rule itself is kept as written. Tests: the proxy-sign-in spec's 302 and 403 cases use separate pages (decided in delivery, pending the maintainer)

Assumption: in a token session, an answer that is not Simlock's (including a not-Simlock 401, e.g. the proxy's own session ended) keeps the token and changes nothing; the live connection shows Reconnecting as today; no identity check and no reload. Tests: ui/src/data/session.test.ts pins that a token session ignores a not-Simlock answer (decided in delivery, pending the maintainer)

Assumption: after a stream loss or a failed request in a proxy session, a 5xx or a timeout from GET /v1/identity counts as unreachable (Reconnecting with today's backoff), not none; at load it still counts as none. Tests: ui/src/data/session.test.ts pins that a 502 from the identity check after a loss keeps the proxy session and enters the backoff (decided in delivery, pending the maintainer)

Done when

  • The tests above pass; pnpm test:console --project=chromium passes.
  • docs/CONSOLE.md has "Behind a sign-in proxy" (what the operator configures, one Cloudflare Access and one oauth2-proxy example, the refusal line), and its "Staying signed in" and Sign out text say what happens behind the proxy.
  • docs/internal/DESIGN.md names "Signed in as" in the sidebar foot.

Out of scope

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Oct 19, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Oct 19, 2026
  3. self-assigned this
    on Oct 19, 2026
  4. V3RON commented on Oct 19, 2026

    @V3RON
    ContributorAuthor

    Handoff

    Done: PR #738 (draft, on task/714): proxy sign-in in the console, "Signed in as", Sign out, the identity check, the reload rule and the loss path. Unit and Chromium console tests pass. Review: round 1, round 2 and a fix-check; R1–R8 fixed and verified.

    Not done: two tests the fix-check found missing (R9, R10, in the PR's Status). Code is believed right; only the tests are missing.

    Findings: three decisions were taken in delivery, each in a ## Decision taken comment on #738 and an Assumption line here: separate tabs for the two reload cases; a token session ignores answers that are not Simlock's; 5xx or timeout after a loss counts as unreachable.

    Blocked on: the review cap (rule 14) with R9 and R10 open; the maintainer confirming or changing the three decisions. Then: one test-only fix run and a fix-check. #717 waits on this.

    Written by an agent.

  5. 4 remaining items

  6. added
    task:ready
    on Oct 19, 2026
  7. self-assigned this
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions