Commit 5f7de94
Verified email attribute (#3637)
Support new identity attributes `verified_email` that are certified by
II only upon evidence that the email address is actually controlled by
the authenticated user.
# Changes
- Added `VerifiedEmail` variant to the `AttributeName` enum for
certifying verified email addresses
- Introduced `OpenIdEmailVerificationScheme` enum with Google and
Microsoft variants, along with corresponding Candid types
- Implemented provider-specific email verification logic: Google uses
`email_verified` claim, Microsoft validates personal account tenant IDs
- Refactored attribute preparation to use dedicated getter methods with
improved maintainability
# Tests
### Verified email attribute tests (`verified_email_tests`)
Sets up real Google and Microsoft providers via `openid::setup` so
`config_issuer()`, `get_verified_email()`, and scope matching all work
end-to-end through `prepare_openid_attributes`.
**Google (`email_verified` claim, case-insensitive):**
- Returns verified email when `email_verified` is `"true"`
- Returns nothing when `email_verified` is `"false"`
- Returns nothing when `email_verified` metadata is absent
- Returns nothing when `email` metadata is absent (even if
`email_verified` is `"true"`)
- Accepts case variations (`"True"`) — verifies case-insensitive check
- Returns nothing when `email_verified` is stored as `Bytes` instead of
`String`
**Microsoft (`tid`-based personal account check):**
- Returns verified email when `tid` matches the personal account tenant
ID
- Returns nothing for enterprise (non-personal) tenant IDs
- Skips credential entirely when `tid` is missing (provider can't
resolve `{tid}` placeholder)
- Returns nothing when `email` metadata is absent
**Combined / cross-cutting:**
- Both Google and Microsoft verified emails returned in a single
multi-credential anchor
- Verified email returned alongside `email` and `name` attributes in one
request
- Credential with unknown issuer (no matching provider) is skipped
entirely
All tests also assert that `requested` is properly drained (empty after
call) when the scope was consumed, or remains non-empty when the
credential was skipped.
---------
Co-authored-by: Arshavir Ter-Gabrielyan <arshavir.ter.gabrielyan@dfinity.org>1 parent 38c745c commit 5f7de94
File tree
11 files changed
+787
-94
lines changed- scripts
- src
- internet_identity_interface/src/internet_identity
- types
- internet_identity
- src
- openid
- tests/integration
- config
11 files changed
+787
-94
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
369 | 374 | | |
370 | 375 | | |
371 | 376 | | |
| |||
375 | 380 | | |
376 | 381 | | |
377 | 382 | | |
| 383 | + | |
378 | 384 | | |
379 | 385 | | |
380 | 386 | | |
| |||
0 commit comments