docs(deploy-to-cloud-engine): pin the II derivation origin at first deploy - #340
Conversation
…eploy The engine console now names an app's canister address as the origin an Internet Identity app should derive from (dfinity/control-panel#3394, #3398). Canisters are the user's to write, so the agent deploying them is the one that has to get this right, and it is not recoverable later: a domain that has already collected sign-ins cannot be repointed at a derivation origin without orphaning every account made under it. The engine-specific part is which URL to use. The console derives the address from the canister marked __META_MAIN_CANISTER: "true" — the same canister whose __META_BASE_URL Step 2 already sets — so the value the agent needs is one it has computed by that point. Mechanics (derivationOrigin, .well-known/ii-alternative-origins, the _headers entry the static-site recipe needs) stay in internet-identity; this only points there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Skill Validation ReportValidating skill: /home/runner/work/icskills/icskills/skills/deploy-to-cloud-engineStructure
Frontmatter
Tokens
Markdown
Tokens
Content Analysis
Contamination Analysis
Result: 1 warning Project Checks |
… origin (#339) # Motivation The skill only mentioned `derivationOrigin` and `ii-alternative-origins` in Pitfall 8, to say don't use them. That is right for the `icp0.io` vs `ic0.app` case it covers, but it was the whole coverage, so an agent adding a custom domain to an II app found a prohibition and no recipe. `custom-domains` Pitfall 9 already pointed here for one. The engine console started surfacing this in dfinity/control-panel#3394 and dfinity/control-panel#3398. # Changes - Added a "Serving an app at more than one origin" section: pick the canister address as the derivation origin, set `derivationOrigin` on the alternative origin only, and serve `.well-known/ii-alternative-origins` from the derivation origin's canister. - Added the `_headers` block the `@dfinity/static-site` recipe needs. The [official docs](https://docs.internetcomputer.org/building-apps/authentication/alternative-origins) say to use `.ic-assets.json5`, which is the legacy asset canister's config — static-site does not read or upload it. The file also has no extension, so it will not serve as `application/json` without a `_headers` entry, and certified-assets sets no CORS header by default. - Scoped Pitfall 8 to the `icp0.io`/`ic0.app` case and pointed it at the new section. - Added one eval case. Dropped a second one I drafted ("which origin gets `derivationOrigin`") because the baseline scored 3/3 on it — it tested common knowledge, not the skill. <details> <summary>Eval 14 — Adversarial: alternative origins on the static-site recipe (WITH 3/3 | WITHOUT 2/3)</summary> ``` ━━━ Adversarial: alternative origins on the static-site recipe ━━━ WITH skill: 3/3 passed ✅ Serves .well-known/ii-alternative-origins containing {"alternativeOrigins": [...]} ✅ Adds a _headers entry setting Content-Type: application/json AND Access-Control-Allow-Origin: * for /.well-known/ii-alternative-origins ✅ Does NOT create a .ic-assets.json5 file WITHOUT skill: 2/3 passed ✅ Serves .well-known/ii-alternative-origins containing {"alternativeOrigins": [...]} ❌ Adds a _headers entry setting Content-Type: application/json AND Access-Control-Allow-Origin: * for /.well-known/ii-alternative-origins → No _headers file or entry is included anywhere in the output. ✅ Does NOT create a .ic-assets.json5 file ``` The baseline writes the JSON file and stops, which leaves it served with the wrong content type and no CORS header. </details> --- Next #340, #341 --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Marco Walz <marco.walz@dfinity.org>
|
Both the new subsection and Pitfall 18 call the derivation origin "the same [value/URL] as
So when Suggest dropping the equivalence: it is the main canister's canister address |
…ntend canister Review feedback on #340. Both the subsection and Pitfall 18 called the derivation origin "the same value as __META_BASE_URL". That variable is allowed to hold a custom domain (lines 151 and 219 say so), and a custom domain is exactly what must never become the derivation origin. The two values agree only at first deploy and diverge in the case the guidance exists for. Also drops __META_MAIN_CANISTER as the anchor. That flag is a console display setting and does not promise the canister serves HTTP. A backend canister cannot be a derivation origin: the browser is never on it, and it cannot serve the .well-known/ii-alternative-origins file II fetches from that origin. The rule now points at the canister that serves the frontend, with the flag demoted to the usual case. Eval 17 carried the same conflation in behavior #2 and is rewritten around a setup where __META_BASE_URL is a custom domain. Note the case does not isolate this fix: the old text also passes it, because the rest of the section contradicts the bad clause. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Good catch, you're right. Fixed in 6a8f4e3.
I also dropped One thing worth flagging, since it cuts against the fix. I rewrote eval 17 around a setup where So the practical blast radius was smaller than my PR description implied, and the eval is a regression guard for the corrected guidance rather than proof of this fix. The text was still self-contradictory and worth correcting on its own. Current numbers are WITH 3/3 | WITHOUT 1/3, with the delta on the I dropped a fourth behavior I had drafted ("lists the custom domain as an alternative origin") because it tests the |
Motivation
The engine console now shows an app's canister address and names it as the origin an Internet Identity app should derive from (dfinity/control-panel#3394, dfinity/control-panel#3398). The console can only tell the user — the canisters are the user's to write, so the agent deploying them is the one that has to act. And it cannot be fixed later: a domain that has already collected sign-ins cannot be repointed at a derivation origin without orphaning every account made under it.
Changes
__META_BASE_URLis not the answer. It is allowed to hold a custom domain, and a custom domain is the one value that must never become the derivation origin.__META_MAIN_CANISTERto the usual case rather than the rule. It is a console display flag and does not promise the canister serves HTTP.internet-identityand linked to it.Eval 17 — Adversarial: II derivation origin when __META_BASE_URL is a custom domain (WITH 3/3 | WITHOUT 1/3)
The case does not isolate the
__META_BASE_URLcorrection. I ran it against the pre-fix text and that scores 3/3 too, because the rest of the section says the canister address "survives adding, changing, or dropping a custom domain", so an agent reads past the bad clause instead of following it literally. Treat this as a regression guard for the corrected guidance, not as evidence for the correction. The correction stands on the text having been self-contradictory.I dropped a fourth behavior I had drafted ("lists the custom domain as an alternative origin") because it tests the
.well-knownmechanics this skill deliberately delegates tointernet-identity.Prev. #339