Studio Step 2: N sign-in chooser entries and an egress-guarded issuer probe (epic &119)
Status: Done (2026-09-27) — !1519
Issues: #568, #570 (epic &119)
Branches: feat/119-studio-step2 (carries this page)
This is a Design + Scope plan. GitLab owns tracking. The plan freezes when U-A starts. It ships as one MR with one battery, because both units restructure the same Step-2 form and template.
Erratum (2026-09-27): D4 as built renders Remove only when there is more than one entry and Add only below MAX_IDP_ENTRIES (a hint replaces it at the limit); the handler still guards both bounds.
Erratum (2026-09-27): D9’s always-refused metadata endpoints also include GCP’s IPv6 metadata address fd20:ce::254 (IPv6-only instances; GCP documentation, retrieved 2026-09-27), and the RFC 8215 local-use NAT64 prefix 64:ff9b:1::/48 is classified private, because its embedded IPv4 follows an operator-chosen layout.
Context
-
Step 2 authors one chooser entry.
-
WizardDraft(services/canopy-web/src/studio/wizard.rs~57-88) holdsidp_slug,idp_label,idp_chip_color,idp_chip_icon,idp_domain_matchandidp_authorize_params. It is stored only in the tower-sessions session (SESSION_KEY, ~91-110). -
The form is parsed as
Form<HashMap<String, String>>(~327), so repeated keys collapse. Step 4 already uses indexed names (programs_{slug}). -
bundle.rsrender_idp_tomlpassesidps: vec, and the round-trip test asserts one entry (~836).
-
-
Studio is stricter than the runtime, and loses input.
-
validate_idp_domain_matchrequires at least one suffix (validation.rs~250-271). The runtime allows an empty list: a chooser-only entry (crates/canopy-composition/src/idp.rs~101-104). -
A 422 re-renders the domain and authorize-param textareas from the parsed draft. Input that failed to parse is therefore wiped (
wizard.rs~510-518, ~638-654).
-
-
The runtime rules for many entries: slugs are unique (
SlugDuplicate);domain_matchis first match in declaration order; a single entry skips the chooser (single_idp()); zero entries refuse canopy-web’s boot (IdpRuntimeError::NoIdpEntries). -
No probe is possible today.
-
Discovery fetches go through a process-global cache keyed by the raw input, with no eviction and no body cap (
crates/canopy-auth/src/discovery.rs~195-325).OidcDiscoveryis#[serde(default)], so{}parses. -
canopy-web’s shared client follows redirects and has no destination policy (
services/canopy-web/src/main.rs~265-269). -
cargo xtask identity verifydoes not check the issuer binding or the exchange-grant advertisement, and its code is private to xtask. -
htmx 2 swaps no 4xx response unless the target carries
data-swap-errorsor the response is a marked denial (services/canopy-web/static/js/canopy-web.js~66-86).
-
Rulings in force:
-
This must work in every jurisdiction without code changes.
-
Pre-1.0 has no compatibility shims.
-
ADR-048: one trusted issuer, deployment-configured.
-
Startup-guard doctrine (
security-operations.adoc~146): default-refuse outsideCANOPY_ENV=development; an environment-only override accepting the literaltrue(canopy_common::env::override_flag_is_true); aWARNwhenever the override is exercised.
Scope
In scope: D1–D10.
Out of scope (GitLab follow-ups, linked from the closing comment):
-
chain-auditing Studio actions (the bundle download and the probe);
-
cargo xtask identity verifyadopting the probe’s checks, which would add its missing issuer-binding and exchange-grant rows; -
a streaming body cap for introspection and the token exchanger, which today buffer a chunked body before comparing;
-
the wizard collecting
[identity].validationand[identity.introspection].
Pre-existing defects, each filed as a fix: issue:
-
every step’s first submit button is Cancel, so Enter in any field cancels the wizard (the new
probe_*fields inherit it); -
a failed resubmit of an earlier step still saves, and the bundle is then built from the invalid draft.
Design
Decisions
| # | Decision | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
D1 |
The epic, restated after &118.
|
|||||||||||||||
D2 |
Draft model.
|
|||||||||||||||
D3 |
Form encoding.
|
|||||||||||||||
D4 |
Add and remove without a new default button.
|
|||||||||||||||
D5 |
Validation across entries, and input kept on error.
|
|||||||||||||||
D6 |
Bundle and review.
|
|||||||||||||||
D7 |
The probe surface.
|
|||||||||||||||
D8 |
The probe’s checks, in a new
|
|||||||||||||||
D9 |
The egress guard (the SSRF decision):
|
|||||||||||||||
D10 |
Throttle and log.
|
Invariants
-
No probed URL reaches the draft, the bundle or
idp.toml. -
The probe never fetches an "always refused" address. Outside development it fetches no loopback address, no private address unless the accountable override is set, and no public address over plain
http. -
The probe connects only to addresses it vetted for that request’s scheme, and never follows a redirect.
-
A probe’s usable key is one runtime validation could use.
-
No response body or raw transport error reaches the page or the log.
-
The bundle’s
idp.tomlround-trips throughIdpDocument::parsefor any 1..=16 entries.
Units — U-A → U-C, one MR
Commit 1 is docs(plans): plan the Studio Step 2 entries and issuer probe (&119). The last is docs(plans): close the Studio Step 2 plan (&119).
U-A (w5) — feat(web): author N sign-in chooser entries in Studio (#568)
Files:
-
services/canopy-web/src/studio/{wizard,validation,bundle}.rs(the new handler ispub(crate)inwizard.rs, registered in itsroutes()); -
templates/studio/_wizard_body_step2.html, a new_wizard_step2_entries.htmlpartial, and_wizard_body_step5.html; -
a new
services/canopy-web/src/studio/step2_route_tests.rs(#[cfg(test)]); -
xtask/src/cmd/route_authz.rs:-
EXPECTED_MUTATING_TOTALgoes from 83 to 84, and its canary comment’s Studio count from 2 to 3; -
a
SCOPE_POLICYrowNotProgramScoped(STUDIO_REASON)for the handler; -
policy_foris unchanged, since it keys on the registering file (studio/wizard.rs, alreadyStudioAdminOnly);
-
-
tests/e2e/specs/studio-onboarding.spec.ts.
Tests:
-
Indexed parsing: count bounds, a missing index, and re-indexing after a remove.
-
A proptest: the parser never panics on arbitrary form maps, and entries → form → entries is the identity.
-
Cross-entry uniqueness of slugs and of domain suffixes.
-
An empty
domain_matchis accepted. This legitimately rewritesdomain_match_requires_at_prefix's empty-list assertion; the commit says why. -
A 422 keeps the raw textarea input.
-
Routed tests in
step2_route_tests.rs, followingauth/validation_error_tests.rs: aRouterwith the handler, the session and CSRF layers, and a seeded studio-admin session. They cover add and remove at the bounds, and a 403 for a non-admin. -
A proptest:
render_idp_tomlover 1..=16 generated valid entries round-trips throughIdpDocument::parse, with order and fields kept. -
Fixtures that move to
idps:wizard_draft_serializes_roundtrip,bundle.rsmake_draft, and the e2e spec’s flatidp_*posts. -
e2e: add two entries with the control, fill them, and see the review list three and the bundle’s
idp.tomlhold three. A duplicate slug gives 422 throughpostStep. -
e2e, delayed response:
page.routeholds the entries response. While it is pending, the entries fieldset and Next are disabled and a second control’s click sends nothing. After release, a field edited before the click keeps its value.
U-B (w5) — feat(web,auth): probe a candidate issuer from Studio (#570)
Files:
-
crates/canopy-common/src/http.rs(pub mod egress;) andhttp/egress.rs(new); the workspace and canopy-commonCargo.toml(rustls); -
crates/canopy-auth/src/issuer_probe.rs(new) anddiscovery.rs(require_issuerbecomespub(crate)); -
canopy-web:
-
studio/wizard.rs(the probe handler,pub(crate), registered inroutes()), -
a new
studio/probe.rs(the limiter and result rendering), -
main.rs(IssuerProbeClient,ProbeLimiter), -
config.rs(RESERVED_KEYS), -
the Step-2 template and a
_wizard_step2_probe.htmlpartial, -
bundle.rs(the README gains an identity section: probe the issuer, then runcargo xtask identity verifybefore deploying);
-
-
crates/canopy-api/src/ratelimit.rs(SharedKeyedLimiter); -
crates/canopy-test-lib/tests/issuer_probe_test.rs(new; canopy-auth has no canopy-test-lib dev-dependency); -
xtask/src/cmd/route_authz.rs:EXPECTED_MUTATING_TOTALgoes from 84 to 85 and the Studio count from 3 to 4, plus aNotProgramScoped(STUDIO_REASON)row for the probe handler.
Tests:
-
EgressPolicy:-
every row of the address table, and the classification order:
[::1]is loopback and admitted in development;::ffff:127.0.0.1is loopback; the NAT64 form of169.254.169.254is refused; -
fd00:ec2::254and100.100.100.200are refused in development and under the override, as literals and as DNS answers; -
the scheme rule per class: under the override,
httpto a private answer is admitted, whilehttpto a public answer, or to mixed public and private answers, is refused.
-
-
GuardedClient, with short timeouts and a fixed-answerlookup:-
http://169.254.169.254/is refused with no network; -
a name whose answer is refused never connects (a counting listener stays at zero);
-
a 302 is refused, not followed;
-
a chunked body over the cap is
TooLarge; -
a delay past the total is
Timeout; -
an
httpsURL at a plain-HTTP listener isTls.
-
-
issuer_probe_test.rsagainst the canopy-test-libMockIssuer, plus small axum stand-ins for the shapes the mock cannot serve. One case perProbeFailure:-
input with a query, a fragment or userinfo;
-
404; not JSON;
-
an issuer with a path, found at
…/realms/x/.well-known/openid-configuration; -
issuer mismatch; no exchange grant;
-
an unusable endpoint (
ftp:andmailto:authorization or token endpoints;httpoutside development); -
a document whose
jwks_uriis an always-refused IP literal; -
an empty JWKS; no usable key, with a fixture for each reason (an EC key under RS256, an RSA key whose
nis malformed, a key withoutkid).
-
-
Pass, with its facts.
-
Routed tests in
step2_route_tests.rs: 200 for pass, fail and identity-invalid; the throttle’s 429; a probe followed by Next and a bundle download leaves noprobe_*value anywhere in the bundle. -
SharedKeyedLimiter: the window admits 6 and refuses the 7th per key; keys are independent; with Redis unreachable it falls back to the process-local limiter, never unlimited. Follow the module’s existing test pattern. -
e2e against the devstack (development policy). The probe cases run serially in the
studio-adminproject only, three probes within one window’s quota of 6, and the spec states its quota budget. Both Studio projects sharejane.studio.-
success at the issuer canopy-web’s own configuration names;
-
IssuerMismatchathttp://keycloak:8080/realms/canopy(Keycloak names itself byKC_HOSTNAME); -
404 at a nonexistent realm.
Connectand the other transport failures are covered offline.
-
U-C (w2) — docs: document Studio’s chooser entries and issuer probe (#570)
Files:
-
docs/modules/ROOT/pages/api/canopy-web.adoc(the two routes); -
authorization-inventory.adoc(the canary count); -
security.adoc(the egress guard); -
security-operations.adoc(the override’s inventory row); -
configuration-reference.adoc(CANOPY_WEB__ALLOW_PRIVATE_ISSUER_PROBE); -
idp-integration.adoc(Studio authors N chooser entries; the probe besideidentity verify); -
guide/administrator.adoc(Step 2); -
CHANGELOG.
Verification
-
Per unit: fmt, clippy, non-live nextest and quality-budgets in isolated worktrees, with no live-devstack tests.
-
CANOPY_CARGO_FEATURES=canopy-api/test-clock cargo xtask dev reload, thengit push. The battery is the gate: the Studio e2e projects run the new specs against the devstack.
Documentation Updates
-
The pages in U-C.
-
GitLab: file the out-of-scope follow-ups and the two pre-existing
fix:issues. Rewrite epic &119’s description, which copied cluster-1 text, with this plan’s link.
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 (2026-09-26) |
Anthropic |
claude-opus-5-5 |
no-ship — seven blockers fixed: * a policy-carrying |
2 (2026-09-26) |
OpenAI |
gpt-6-astra |
no-ship — eight findings fixed in revision 3: * resolve, vet and pin per request, since a reqwest resolver cannot see the scheme (mixed answers refused);
* the IPv6 and Alibaba metadata endpoints always refused, ahead of the private ranges;
* No round 3. |