Repository navigation
fix(local): drop the callback allow-list II can't fetch from loopback - #172
Merged
Merged
Conversation
The local login listener served `/.well-known/ii-auth-callbacks` so II's #4091 check would honour its callback. That check cannot run against a local server: browsers block II's https document from fetching a loopback URL, so the request never arrives and, since the check is fail-closed, every local sign-in would be refused. II therefore exempts a server on loopback from the allow-list and takes the callback as given (dfinity/internet-identity#4305). It trusts a local server by loopback host rather than by exact origin, stored port-less as `http://127.0.0.1`, which is what lets this listener keep binding port 0 for a fresh port per handshake. Standing in the check's place are the user's deliberate opt-in to a local connector in II Settings, II's notice before the first local sign-in for an identity on a machine, and its consent screen on every connect. So the route is dead weight, and its doc comment ("fail-closed, so serving this document is mandatory") now describes something that never happens. Remove it, leaving the handshake two routes: the pinned callback page and the slim redeem. The hosted server keeps serving its allow-list — II still enforces it for an https origin. Also record why `state` is load-bearing here in a way it isn't for a hosted server: a hosted callback sits on a domain a random page can't reach, while this listener is reachable by any page in the browser and any process on the machine, so an unguessable `state` (a v4 UUID) is what stops a forged POST to `/redeem` from injecting an identity the user never chose. II treats it as opaque and only echoes it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Removes the local callback allow-list now that Internet Identity’s paired loopback support exempts local servers.
Changes:
- Reduces the login listener to callback and redeem routes.
- Updates unit and end-to-end coverage.
- Revises deployment documentation for loopback trust.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
README.md |
Documents the hosted-only allow-list requirement. |
docs/scoping-local-deployment.md |
Updates local listener design and verification notes. |
docs/local-deployment.md |
Describes the two-route login flow. |
crates/imcp2-local/src/login/tests.rs |
Verifies retired paths return 404. |
crates/imcp2-local/src/login/routes.rs |
Removes the allow-list route and state. |
crates/imcp2-local/src/login/mod.rs |
Simplifies router setup and updates security rationale. |
crates/imcp2-local/src/e2e_local_login.rs |
Models port-less loopback trust without allow-list fetching. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…llowlist # Conflicts: # crates/imcp2-local/src/e2e_local_login.rs # crates/imcp2-local/src/login/routes.rs # crates/imcp2-local/src/login/tests.rs
Three follow-ups from the review, all documentation: The `state` rationale was wrong about why the hosted flow is safer. A hosted callback is publicly reachable by arbitrary pages too — what it has is a separate *initiator* proof, the `sid` cookie set at its public `/oauth/authorize` (`CONNECT_COOKIE`, `src/auth.rs`). This flow has no such endpoint and so no cookie, which leaves two things standing for the initiator: `state`, and the delegation's final hop toward the `X` minted in this process. Naming only `state` implied the chain requirement was incidental, which could mislead a later change; say both. `iiconnect.rs` still described the `#4091` allow-list as binding every embedding binary and mandatory, while `imcp2-local` builds a connect link without serving one. Qualify it as a remote callback's obligation and say why loopback is exempt. Two passages in the scoping doc still described the three-route listener and derived a well-known entry from the callback origin, contradicting the two-route design the rest of the document now states. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
aterga
approved these changes
Sep 3, 2026
aterga
pushed a commit
that referenced
this pull request
Sep 22, 2026
Resolves the conflict in deploy/native/deploy.sh between this branch's OAUTH_CIMD_ENABLED substitution on the unit_mcp line and #194's SERVE_STATUS block around the caddyfile line: both are kept, the CIMD comment and substitution first, then the status block as main has it. The other files main touched (#172, #194, #195) merged cleanly. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd7VT72Qt16qiAJynu9EKj
9 tasks done
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.
Pairs with dfinity/internet-identity#4305.
Why
The local login listener serves
/.well-known/ii-auth-callbacks(login/routes.rs) so II's #4091 check will honour its callback. That check can't run against a local server: browsers block II's https document from fetching ahttp://127.0.0.1URL, so the request never arrives — and because the check is fail-closed, every local sign-in is refused. The route's own doc comment ("fail-closed, so serving this document is mandatory") describes something that never happens.II now exempts a server on loopback from the allow-list and takes the callback as given. It trusts a local server by loopback host rather than by exact origin, stored port-less as
http://127.0.0.1— which is exactly what lets this listener keep binding port 0 and getting a fresh port per handshake. Standing in the check's place: the user's deliberate opt-in to a local connector in II Settings, II's notice before the first local sign-in for an identity on a machine, and its consent screen on every connect.What changes
login/routes.rs— theauth_callbacksroute and handler go. The handshake is two routes now: the pinned callback page and the slim redeem.RouteCtxlosescallback_url(it existed only to fill the allow-list document), sologin_routerloses that parameter.login/mod.rs— the module doc no longer cites #4091 as a reason the listener must exist; the fragment still needs a served page to read it, which is reason enough. The port-0 comment no longer claims the callback and an allow-list entry must not drift.login/tests.rs— the surface test now asserts the listener serves the pinned page and nothing else, 404-ing the retired well-known along with any other path.e2e_local_login.rs— drops the allow-list fetch step, and sets the anchor's trusted URL tohttp://127.0.0.1(the shape a local login actually runs against) rather than an arbitraryhttp://localhost:8000/mcp.The hosted server is untouched — II still enforces the allow-list for an https origin, and
src/auth.rs/src/lib.rskeep serving it.Also
Records why
stateis load-bearing here in a way it isn't for a hosted server. A hosted callback sits on a domain a random page can't reach; this listener is reachable by any page in the browser and any process on the machine, so an unguessablestate(already a v4 UUID) is what stops a forged POST to/redeemfrom injecting an identity the user never chose. II treats it as opaque and only echoes it, so keeping it unpredictable is entirely this side's job.Verification
cargo test -p imcp2-local— 21 passed.cargo check -p imcp2-local --features e2eclean.cargo fmt --checkandcargo clippy -p imcp2-local --all-targetsproduce byte-identical output before and after this change (the tree has 518 pre-existing fmt diffs onmain, 3 of them in this crate, all inserver.rsand untouched here).Merge order
This can land first — local login doesn't work against
main-era II either way, since that gate rejects a loopback callback before the allow-list is ever consulted. But it only becomes useful once #4305 ships.🤖 Generated with Claude Code