Skip to content

feat(console): offer proxy SSO sign-in alongside operator tokens - #1632

Merged
V3RON merged 3 commits into
callstackincubator:mainfrom
bheemreddy-samsara:bheemreddy-samsara/console-sso-sign-in
Nov 20, 2026
Merged

V3RON merged 3 commits into
callstackincubator:mainfrom
bheemreddy-samsara:bheemreddy-samsara/console-sso-sign-in

Conversation

@bheemreddy-samsara

@bheemreddy-samsara bheemreddy-samsara commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add optional http.proxyAuth.signInUrl so worker and gateway consoles can open a fixed proxy-login URL in the same tab. Keep the token form and refusal reason visible, and show the link on the ended-session screen.

The strategy owns the URL. Only GET /v1/identity adds it to a 401; other routes and 403 bodies stay unchanged. OpenAPI and ADRs document that scope. A {path} in the URL becomes the page the person was on. Protocol bounds move together from 101 to 102.

Validation

Head: 925bd78eb.

  • Affected suite at 171bb2847: pnpm test:changed 7,450 passed, two skipped; pnpm typecheck clean. 925bd78eb adds two test rows only.
  • {path}: config accepts a template and refuses one that is no longer http/https after substitution, including https://{path}/start, which parses as written (src/core/config-auth-and-proxy.test.ts); the console replaces {path} with the encoded path and search and drops that same template (ui/src/model/sign-in-url.test.ts, ui/src/app/sign-in.dom.test.tsx). Mutation probes: checking the URL as written, in the schema or in signInHref, fails a test.
  • A refused proxy JWT still shows the SSO link and the refusal line (ui/src/app/proxy-sign-in.dom.test.tsx); deleting the signInUrl spread in ui/src/data/session.ts fails it.
  • CI at 925bd78eb: running.

Review

Spec review: skipped. Code review: 1 blocking, 1 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 0 notes.
Rounds: 1. Tokens: 1.8M.
Runs: 9. Cost USD: 4.2324. Agent seconds: 2032.

Assessment: complete

Workflow

flowchart LR
  A[Unsigned console] --> B[Identity check returns login URL]
  B --> C[SSO link opens proxy login]
  C --> D[Existing proxy identity]
  A --> E[Operator token form]
  F[Repeated session loss] --> G[Ended screen with SSO link]
Loading

Merge risk

Merge risk: medium

Alignment: good ✅ — Matches the maintainer's revised design.

Impact: medium 👀 — Touches auth metadata; permissions stay unchanged.

Verification: good ✅ — Unit, browser, real-proxy and mutation checks pass.

Rollback cost: medium 👀 — Protocol 102 requires coordinated gateway/worker upgrades or rollback.

Error detection: decent 👀 — CI covers response shapes and console sign-in.

Status

Implement: done ({path} + R1 test) Review: round 1 + fix-check passed at 925bd78, 0 open Hardware: n/a Gate: not run
Next: maintainer marks ready and merges once CI is green

Written by an agent.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The proxy-auth configuration accepts an optional HTTP or HTTPS sign-in URL with a maximum length of 2048 characters. The gateway exposes the URL through authentication and includes it in identity-route 401 responses. The console validates and retains the URL, then displays a same-tab SSO link when available. Tests and documentation cover configuration, response handling, session behavior, and the sign-in flow. The protocol version range changes from version 101 to version 102.

Suggested reviewers: v3ron

Merge Risk: Minimal · up to 925bd

This adds an optional same-tab SSO sign-in link to the console. The link appears only when a proxy sign-in URL is configured, and only the identity route's 401 response carries it. The token form remains available. No actionable merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: an optional proxy SSO sign-in link shown alongside the operator-token form in the console. The raw summary and objectives confirm this (signInUrl, same-tab link, token…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states that the PR adds optional http.proxyAuth.signInUrl so worker and gateway consoles can open a proxy-login URL in the same tab, keeps the token form visible, shows the link on the…
Full details: Title check

Explanation

The title names the main change: an optional proxy SSO sign-in link shown alongside the operator-token form in the console. The raw summary and objectives confirm this (signInUrl, same-tab link, token form kept). The title is concise and specific.

Full details: Description check

Explanation

The description states that the PR adds optional http.proxyAuth.signInUrl so worker and gateway consoles can open a proxy-login URL in the same tab, keeps the token form visible, shows the link on the ended screen, limits the 401 change to GET /v1/identity, and covers {path} substitution and protocol range 101 to 102. These points match the changeset (config schema, auth strategy, HTTP identity route, console sign-in screens, docs, and protocol constant), so the description is related and specific.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 9de563af-9fdd-45e5-8b72-7ae6a73a934b
Commits

Reviewing files that changed from the base of the PR and between 171bb28 and 925bd78.

Files selected for processing: 2

  • src/core/config-auth-and-proxy.test.ts
  • ui/src/model/sign-in-url.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@bheemreddy-samsara
bheemreddy-samsara marked this pull request as ready for review November 17, 2026 05:34
@bheemreddy-samsara

Copy link
Copy Markdown
Contributor Author

@V3RON would love your thoughts

@V3RON

V3RON commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for this. The gap is real: a proxy that lets the unsigned console page through (oauth2-proxy with skip-auth routes, for example) leaves a person with only the token form. The console side of this PR (the scheme check, the same-tab link, keeping the token form) looks good.

Where the URL comes from and where it goes needs to change, though. Here are the problems, then the design we'd like.

Problems with the current approach

  1. It breaks ADR 0033. The ADR says a refusal's message and details come from the strategy that refused, never from the host. Here createAuthFrom in src/auth/index.ts reads options.config.proxyAuth?.signInUrl itself and adds it to every refusal, the token strategy's "Unknown bearer token" included. The auth core now knows about a proxy-only setting.
  2. Every 401 on every route changes. CLI, MCP clients, agents with a bad token and the /v1/session WebSocket all get error.signInUrl now, and bodies that had no details change shape. Only the console's GET /v1/identity check needs the URL.
  3. The ended screen has no link. After a second session end within a minute the console stops at ended, so with the proxies this is for, a person whose JWT expired is stuck.
  4. The return path is fixed. With rd=/, a deep link such as /leases/<id> is lost after login.
  5. The protocol bump is stale. Main is at protocol 100 now.

Proposed design

In short: the proxy strategy owns signInUrl, auth hands it on as a plain value, and only GET /v1/identity adds it to its 401 body.

1. Auth: the strategy offers the URL, the core passes it on

src/auth/strategy.ts: a strategy may offer a fixed sign-in URL, taken from its own config when it is created. AuthError stays as it is.

export interface AuthStrategy {
  authenticate(request: AuthRequest): Promise<StrategyAnswer>;
  /** Where a person starts this strategy's sign-in, when it has one. */
  readonly signInUrl?: string;
}

src/auth/strategies/proxy-jwt/index.ts keeps your signInUrl schema (http/https, at most 2048 characters, plus the {path} check below), and create sets signInUrl from its config.

src/auth/index.ts: Auth gets one read-only field, the first enabled strategy's URL, so the core never names a config key. authenticateRequest stays as it is.

export interface Auth {
  // ...existing
  readonly signInUrl?: string;
}

const signInUrl = strategies.find((s) => s.signInUrl !== undefined)?.signInUrl;

2. HTTP: only the identity route adds it

src/http/auth.ts: requireAuth takes an option. A 401 gets signInUrl next to code, message and reason/details when they exist. A 403 never gets it.

export function requireAuth(
  auth: Pick<Auth, "authenticateRequest">,
  options: { readonly signInUrl?: string } = {},
): MiddlewareHandler<AuthEnv>

src/http/app.ts:

const agentAuth = requireAuth(deps.auth);
const identityAuth = requireAuth(deps.auth, { signInUrl: deps.auth.signInUrl });
// ...
app.openapi({ ...identityRoute, middleware: [identityAuth] }, ...)

src/http/route-declarations.ts: declare the optional error.signInUrl on identityRoute's 401 so the OpenAPI document shows it. No other route changes.

3. Console: your code, plus two additions

  • The ended outcome and state carry signInUrl too, and the ended screen shows the same Sign in with SSO link.
  • A {path} placeholder keeps the page the person was on. Proxies spell the return parameter differently (rd= on oauth2-proxy, other names elsewhere), so the operator writes it into the URL, for example https://fleet.example.com/oauth2/start?rd={path}.
    • The console replaces {path} with encodeURIComponent(location.pathname + location.search) when it builds the link. A URL without {path} is used as written.
    • The daemon's schema checks the URL with a sample path substituted, so a template that stops being an http/https URL fails when the config loads.
    • The console's scheme check runs on the substituted URL.

4. Contract, protocol, ADR, docs

  • Keep the signInUrl mirror in src/contract/config-schemas.ts. It changes the config.get shape, so after rebasing on main, bump PROTOCOL_VERSION_RANGE to 101 and move min with it (src/contract/AGENTS.md).
  • A sixth http.proxyAuth key amends ADR 0033 §3 ("configured by five keys") and touches ADR 0011 §6 (console sign-in). Please add an amendment to ADR 0033 that names the key, says the strategy owns it, that only GET /v1/identity returns it, and describes {path}.
  • Docs: keep the new rows in access-control.mdx and configuration.mdx, but change the paragraph that says every 401 carries the URL: only GET /v1/identity does now. Document {path} with the oauth2-proxy example.

5. Tests

  • Auth: Auth.signInUrl is set when the proxy is configured with the key. It is absent without the key, and absent with only token auth.
  • Config: a URL with {path} is accepted. A template that stops being an http/https URL after substitution is refused.
  • HTTP: GET /v1/identity answers 401 with signInUrl for a missing token, an unknown slk_ token and a refused JWT (with reason kept). GET /v1/status answers the same 401 without signInUrl, and a 403 (a worker join token) has none.
  • Console: your DOM and e2e tests, plus the link on the ended screen, plus {path} replaced by the current path and search, encoded.

Happy to answer questions on any of this.

Written by an agent.

@V3RON

V3RON commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Review of head 690594050. This builds on V3RON's comment above and does not repeat all of it.

Better solution

The problem. Some proxies (oauth2-proxy with skip-auth routes, for example) let the unsigned console page and GET /v1/identity reach Simlock. A person without a proxy session then sees only the token form and has no way to start the proxy's login from the console. Proxies that redirect every unsigned page (Cloudflare Access) already work through the reload in ADR 0033 §7.

Is the approach right? The console half is right: an operator-set URL, a scheme check, a same-tab link and the token form kept. Nothing simpler exists in Simlock today. The console cannot guess a proxy's login route, so a config key is needed.

The daemon half puts the URL in the wrong place. I agree with the design in the comment above:

  • The proxy strategy owns signInUrl and exposes it as AuthStrategy.signInUrl. Auth passes on the first one it finds. createAuthFrom stops reading options.config.proxyAuth. Today it does, which breaks ADR 0033 §2 ("a refusal's message and details come from the strategy that refused, never from the host").
  • Only GET /v1/identity adds error.signInUrl to its 401. Every other route keeps today's body. Only the console reads the URL, and it reads it from that one route.
  • The ended screen shows the link too.

One change to that design: leave {path} for a follow-up. It needs a template rule, a check of the substituted URL at config load, and a console substitution step, all for deep links. A fixed URL plus rd=/ in the docs covers the reported problem. {path} can be added later without breaking anything, because a URL with no {path} is used as written.

Side effects

  • Every 401 changes on every route, on both modes. CLI --url, agents, MCP clients over HTTP, module routes and the /v1/session WebSocket upgrade all get error.signInUrl once the key is set. A 401 that had no details now has an error object with an extra key. Simlock's own client ignores it, but a third-party client that checks the body strictly could break. The docs then tell headless clients they "may use it", which turns it into public API. This is the main reason to limit it to /v1/identity.
  • OpenAPI. No route declares signInUrl, so the generated document does not show a field that every 401 can now carry. With the identity-only design, declare it on identityRoute's 401 only.
  • Protocol and merge. The PR does not merge cleanly: src/contract/protocol.ts conflicts. Main is at { min: 101, max: 101 }, so after a rebase this needs { min: 102, max: 102 }. The number in the comment above (101) is already taken. A gateway and its workers then have to upgrade together, as for every contract change.
  • Refused JWT loop. When the proxy's JWT is refused for a reason that does not change on a new login (audience or issuer mismatch, keys-unavailable), the link sends the person to the proxy, which hands back the same bad JWT. That loop is acceptable because the refusal line is still shown. The docs should say the link does not fix a misconfigured proxy.
  • Workers. http.proxyAuth applies on a worker too ("Both" in the config table), so a worker's own console also gets the link. That is fine, but the docs only describe the gateway case.
  • No effect on leases, seeds, drivers, defaults or performance. The key is optional, has no default, and nothing outside auth, HTTP and the console reads it.
  • Docs. The access-control.mdx paragraph about "every 401 carries the URL" has to change to match whatever the daemon ends up doing. Add an ADR 0033 amendment for the sixth key (§3 says "five keys").

Review

Blind pre-merge review (code and claims lenses; no spec lens, because the PR closes no issue), round 1 at 690594050.

Blocking

  1. R1, src/contract/protocol.ts:13. The range 89..92 reuses 92, which main has already given to another shape (main is 101..101), and it leaves min where it was. Rebase on main, then bump to main's number + 1 and move min with it, since no side-by-side compatibility path stays (src/contract/AGENTS.md).
  2. R2, ui/src/data/session.ts:73. No test checks that a person whose proxy JWT was refused (for example expired) still gets the SSO link. If you delete the signInUrl spread on that line, all 13 ui-dom tests still pass. Add a DOM test where /v1/identity answers 401 with both reason and signInUrl, and check that the refusal line and the link both show.

Checked and fine: the config-schemas.ts mirror, the 401 body merge in requireAuth, who can read signInUrl through config.get, and the console's http/https check. The claims lens found no false statements, including the unchanged UNAUTHENTICATED row in errors.mdx.

Next: after the rebase and the redesign above, a second review round covers the new code.

Written by an agent.

@bheemreddy-samsara
bheemreddy-samsara force-pushed the bheemreddy-samsara/console-sso-sign-in branch from 6905940 to 5141bab Compare November 20, 2026 00:26
@V3RON

V3RON commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Review ledger

Round 1: 171bb28
Round fix-check: 925bd78

Runs: 9. Cost USD: 4.2324. Agent seconds: 2032.
Tokens input 267, output 76769, cache read 7961542, cache write 581209.
- review 1 reviewer: claude-sonnet-5-5 289 s $0.1677
- review 1 code behaviour: claude-opus-5-5 237 s $1.0785
- review 1 claims: claude-sonnet-5-5 25 s $0.1461
- fix implementer: claude-sonnet-5-5 589 s $0.5738
- review 1 reviewer: claude-sonnet-5-5 383 s $0.2904
- review 1 code both: claude-opus-5-5 288 s $1.3513
- review 1 claims: claude-sonnet-5-5 59 s $0.2572
- fix 1 implementer: claude-sonnet-5-5 55 s $0.1827
- review fix-check reviewer: claude-sonnet-5-5 107 s $0.1847
Finding outcomes: {"fixed":1}. Classes: {"testing 2":1}.
{"findings":[{"id":"R1","role":"code","class":"testing 2","outcome":"fixed","fix":"925bd78ebc16d4794308101750e34cf30433a359","path":"src/core/config-auth-and-proxy.test.ts","round":"1"}]}

Written by an agent.

@V3RON
V3RON merged commit 825608e into callstackincubator:main Nov 20, 2026
75 of 77 checks passed
V3RON added a commit that referenced this pull request Nov 20, 2026
## Summary

Rewrites the website docs as task pages and concept pages, 63 pages in
all:

- **Task page:** one task: a `Result:` line, *Before you start*, steps
that end in a `Check:` line, and a *When it fails* table.
- **Concept page:** what a feature is and how it behaves, with no steps.

Getting started has one install page per OS (macOS, Linux, Windows
preview). New sections: Concepts and Troubleshooting. New reference
pages: MCP tools, Node client and Web console. Each fact lives on one
page; other pages link to it.

Also:

- Removed URLs redirect to their new pages.
- The docs links in the CLI, the console, the manuals and `README.md`
point at the new pages.
- The sidebar sections in `website/src/site/pages.ts` name the new
folders.
- SSO sign-in (#1632) and the gateway catalog wait (#1788) are
documented.
- Docs the code contradicted are fixed.

## Validation

- [x] `pnpm --dir website build`: 140 pages, no broken internal links
- [x] `node website/scripts/check-openapi.mjs`
- [x] `pnpm test:changed` (3610 passed)
- [x] `pnpm typecheck`
- [ ] Walk each install page on a clean machine

## Review

Spec review: skipped. Code review: 0 blocking, 0 fixed, 0 notes. Claims
review: 2 blocking, 2 fixed, 0 notes.
Assessment: complete
Rounds: 2. Tokens: 18.8M.

- claims: Ctrl-C on a waiting `simlock lease` cancels the request
(`concepts/queue-and-capacity`), fixed in 4a580f9.
- claims: a phone is not erased after a lease; only apps added since
enrolment are removed (`using-devices/keep-a-device`), fixed in
4a580f9.

*Written by an agent.*
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