Skip to content

docs(authentication): use mo:core/CallerAttributes for the Motoko backend example#207

Merged
marc0olo merged 1 commit intodfinity:mainfrom
sea-snake:docs/ii-caller-attributes
May 6, 2026
Merged

docs(authentication): use mo:core/CallerAttributes for the Motoko backend example#207
marc0olo merged 1 commit intodfinity:mainfrom
sea-snake:docs/ii-caller-attributes

Conversation

@sea-snake
Copy link
Copy Markdown
Contributor

Summary

Companion to dfinity/icskills#182. Updates the Motoko backend example on the Internet Identity guide to use mo:core/CallerAttributes (motoko-core v2.5.0+) instead of the manual Prim.callerInfoSigner / Prim.callerInfoData dance.

  • CallerAttributes.getAttributes<system>() : ?Blob returns the bundle and traps when the signer isn't listed in the canister's trusted_attribute_signers env var. The hardcoded II principal moves out of code and into deploy config.
  • Drops the mo:prim import on the Motoko path (the wrapper handles primitives + signer comparison).
  • Adds an icp.yaml settings.environment_variables snippet for declaring trusted_attribute_signers.
  • Splits the per-language intro and the 'common mistakes' bullet so the Rust path (still requires explicit msg_caller_info_signer() check, no CDK wrapper yet) stays distinct from Motoko.

npm run build passes; no new agent-docs warnings on the affected file.

Sync recommendation

informed by caffeinelabs/motoko-core (src/CallerAttributes.mo); dfinity/icp-cli (docs/reference/canister-settings.md#environment_variables); dfinity/icskills (skills/internet-identity/SKILL.md companion PR #182)

The Motoko side now uses CallerAttributes.getAttributes<system>() from
mo:core (>= 2.5.0). The wrapper bakes in the trusted-signer check via
the canister's trusted_attribute_signers env var, so the example no
longer hardcodes the II principal in code: it moves to icp.yaml as
deploy-time config.

Notable changes:

- Drops the mo:prim import on the Motoko path. The wrapper handles the
  caller-info primitive calls and the signer comparison.
- Splits the prose intro into a per-language list, since the Rust path
  is unchanged (no ic-cdk wrapper for the trusted-signer check yet).
- Adds an icp.yaml settings.environment_variables snippet showing how
  to declare trusted_attribute_signers.
- Updates the "common mistakes" bullet to describe both paths.
@marc0olo marc0olo merged commit c9a6f59 into dfinity:main May 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants