Repository navigation
Identity tools take derivation_origin only (drop app_url) — resolve once, reuse - #64
Merged
Merged
Conversation
Follow-up to the guessed-domain work (#57). The identity-bearing tools no longer accept an `app_url` to auto-resolve — they take ONLY `derivation_origin`: - call_canister, get_app_principal, list_app_accounts: `app_url` removed. - run_canister_oql_query / get_canister_oql_schema were already derivation_origin-only; NOT extended with app_url (the earlier "uniformity via app_url" idea, reversed). Rationale: a derivation origin is a STABLE per-app value, and the server is stateless, so accepting a URL on every call re-resolved it (a network round-trip) every time — and having two ways to identify an app invites the inefficient path. Now the app is resolved ONCE via open_app / resolve_app (which run the guessed-domain gate and return the derivation origin) and that origin is reused across calls. One obvious way in; zero repeated resolution. The guessed-domain gate is unaffected: it lives at the resolver step (open_app/resolve_app), which is on the critical path anyway (you resolve to get the canister id). `derivation_origin` remains trusted verbatim (ungated) — that's the deliberate escape hatch — so this opens no new hole (a fabricated derivation_origin was always ungated); it removes a gated shortcut in favor of efficiency + a single contract. resolve_identity_target is now derivation_origin-only and synchronous; IdentityTarget drops the unused application_origin field; identity_annotation drops its now-unreachable app_url_default branch; derivation_origin_source on these tools is always "explicit" (the declared/known/app_url_default sources are reported by the resolver tools). Tool descriptions, arg schemas, server instructions, and README updated; app_url-path unit tests retargeted to clean_app_url. Full suite: 119 passed. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01NDKdKM6Nhp3z8xxJEDqToh
There was a problem hiding this comment.
Pull request overview
This PR simplifies the “act as user at app” tool surface by removing the app_url identity path and requiring callers to use the app’s canonical derivation_origin (resolved once via open_app/resolve_app) across identity-bearing operations, avoiding repeated URL resolution on a stateless server.
Changes:
- Removed
app_urlfromcall_canister,get_app_principal, andlist_app_accounts, and maderesolve_identity_targetderivation-origin-only and synchronous. - Updated tool descriptions/server instructions and identity annotations to reflect the derivation-origin-only contract.
- Retargeted/updated tests and README documentation to match the new API surface.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main.rs | Drops app_url identity resolution, updates tool docs/instructions, and refactors resolve_identity_target + related tests. |
| src/identities.rs | Updates identity tool argument/output docs to be derivation-origin-only and removes app_url fields from argument structs. |
| src/calls.rs | Removes app_url from call_canister args and updates output field documentation accordingly. |
| README.md | Updates public documentation to describe the derivation-origin-only identity flow and tool signatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…rincipal/list_app_accounts These two tools always act as an app account — they errored at runtime when derivation_origin was omitted — but modeling it as Option<String> with #[serde(default)] advertised it as OPTIONAL in the generated MCP schema, so a client/model could omit it and only hit the requirement at call time. It's now a required `String` (keeping the `domain` alias), so the schema marks it required and validation fails up front. Handlers pass Some(derivation_origin) into resolve_identity_target. call_canister keeps Option<String> — there, omitting it is a valid anonymous call. Full suite: 119 passed. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01NDKdKM6Nhp3z8xxJEDqToh
Comment on lines
+496
to
501
| // `derivation_origin` is a required String here, so this always yields a | ||
| // target (never the anonymous None) unless it fails validation. | ||
| let target = match resolve_identity_target(Some(derivation_origin)) { | ||
| Ok(Some(t)) => t, | ||
| Ok(None) => return Ok(err("provide `derivation_origin` or `app_url` to identify the app".into())), | ||
| Ok(None) => return Ok(err("`derivation_origin` must not be empty".into())), | ||
| Err(e) => return Ok(err(e)), |
Comment on lines
+551
to
556
| // `derivation_origin` is a required String here, so this always yields a | ||
| // target (never the anonymous None) unless it fails validation. | ||
| let target = match resolve_identity_target(Some(derivation_origin)) { | ||
| Ok(Some(t)) => t, | ||
| Ok(None) => return Ok(err("provide `derivation_origin` or `app_url` to identify the app".into())), | ||
| Ok(None) => return Ok(err("`derivation_origin` must not be empty".into())), | ||
| Err(e) => return Ok(err(e)), |
aterga
pushed a commit
that referenced
this pull request
Jul 17, 2026
Main advanced to 88984cb, notably #64 "Identity tools take derivation_origin only (drop app_url)", which overlapped this branch's changes. Reconciliation: - README tools table (the only textual conflict): kept this branch's rows for get_canister_candid (oql + api_doc_available flags) and get_canister_api_doc (structured available/expected/retry/next), and took main's rows for call_canister / get_app_principal / list_app_accounts (app_url dropped — derivation_origin only). - main.rs / calls.rs auto-merged textually but had semantic staleness from the app_url drop, fixed here: the call_canister empty-read note hint, open_app's "Next:" text, and the server-instructions MY/OUR block no longer offer app_url for the identity tools; the is_anonymous doc comment dropped its app_url mention. - This branch's require-origin guards on the OQL read tools, capability-flag enrichment, and empty-read diagnostics all survive alongside main's resolve-once restructure. cargo build + cargo test --all-targets pass (124 tests); no conflict markers, no stale identity-tool app_url references remain. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HRpq9CvXFNhkr2roH7j22d
aterga
pushed a commit
that referenced
this pull request
Jul 28, 2026
Rebased onto main after #64 (identity tools take derivation_origin only), reconciliation is now carried by #66, so this narrows to the non-auth improvements that main still lacks: - call_canister: document the candid? arg; state the OQL query-call rejection accurately (fires when get_canister_candid reports oql: true, not on any OQL canister). - discover: reframe open_app as the one-call entry point; note the domain argument accepts a domain or URL. - App Connect: add the SSRF-hardening note (CWE-918), scoped precisely (user-supplied fetches are address-pinned; dashboard/registry enrichment uses the redirect guard only). - OQL: define the CWE-674 guard (1 MiB / 128-depth pre-parse check over textual Candid; the OQL query path is JSON and only shares the size cap). - Creating canisters: correct the CMC recovery hint (re-notify with the same arguments; the block index alone is not enough). - Run/Deploy: self-contained binary via include_str!; OAUTH_CLIENTS_FILE is always used (default oauth-clients.json, read on startup, best-effort write), needs a writable path; graceful SIGTERM/SIGINT drain; landing page. - Try it: fix the stateless plain-JSON example (drop the SSE parsing and session-id dance, show the bearer token, label the read anonymous). - Domain identities: correct the stale custom-derivation-origin note (the app_url path resolves declared/known origins via resolve_app; only a raw derivation_origin is used verbatim). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the guessed-domain work (#57). Makes the identity-bearing tools identify an app one way — by its canonical
derivation_origin, resolved once — instead of also accepting a websiteapp_urlthat the stateless server re-resolves on every call.Change
call_canister,get_app_principal,list_app_accounts: theapp_urlparameter is removed; they take onlyderivation_origin.run_canister_oql_query/get_canister_oql_schema: alreadyderivation_origin-only; deliberately not extended withapp_url(this reverses the earlier "uniformity viaapp_url" idea in favor of uniformity viaderivation_origin).open_app/resolve_appare unchanged — resolving a name/URL to the derivation origin is their job, and they still run the guessed-domain gate.Why
A derivation origin is a stable per-app value. On a stateless server, accepting a URL on every identity call re-resolved it (a network round-trip) each time, and offering two ways to identify an app invites an agent down the inefficient path. Now the app is resolved once (
open_app/resolve_appreturn thederivation_origin) and that origin is reused across calls — one obvious contract, zero repeated resolution. In practice the origin is already in hand: you callopen_app/discover_app_canistersto get the canister id anyway, andopen_appreturns the derivation origin alongside it.Safety
The guessed-domain gate is unaffected — it lives at the resolver step (
open_app/resolve_app), which is on the critical path (you must resolve to get the canister id).derivation_originstays trusted verbatim (ungated) — the deliberate escape hatch for custom / non-IC-hosted II origins — so this opens no new hole (a fabricatedderivation_originwas always ungated); it removes a gated shortcut in exchange for efficiency and a single contract. Prompt steering + thederivation_originfield description continue to say "get it fromopen_app/resolve_app, never guess."Mechanical fallout
resolve_identity_targetis nowderivation_origin-only and synchronous;IdentityTargetdrops the (already dead-code)application_originfield;identity_annotationdrops its now-unreachableapp_url_defaultbranch;derivation_origin_sourceon these tools is always"explicit"(thedeclared/known/app_url_defaultsources are reported by the resolver tools). Tool descriptions, arg schemas, the server instructions, and the README are updated; the oldapp_url-path unit tests are retargeted toclean_app_url.Note: breaking change to
call_canister/get_app_principal/list_app_accountssignatures (thedomainalias forderivation_originis retained). Fine for the MVP/preview surface.Tests
Full suite: 119 passed, 0 failed locally (offline unit + live discovery/identity). The tool count is unchanged (26).
🤖 Generated with Claude Code
https://claude.ai/code/session_01NDKdKM6Nhp3z8xxJEDqToh
Generated by Claude Code