Skip to content

Commit 5f7de94

Browse files
sea-snakeaterga
andauthored
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

11 files changed

+787
-94
lines changed

scripts/build

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
set -euo pipefail
3+
set -xeuo pipefail
44

55
# Make sure we always run from the root
66
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -84,14 +84,14 @@ if [ ${#CANISTERS[@]} -eq 0 ]; then
8484
CANISTERS=("internet_identity")
8585
fi
8686

87-
# Checking for dependencies
88-
if [[ ! "$(command -v ic-wasm)" || "$(ic-wasm --version)" != "ic-wasm 0.8.5" ]]
89-
then
90-
echo "could not find ic-wasm 0.8.5"
91-
echo "ic-wasm version 0.8.5 is needed, please run the following command:"
92-
echo " cargo install ic-wasm --version 0.8.5"
93-
exit 1
94-
fi
87+
# # Checking for dependencies
88+
# if [[ ! "$(command -v ic-wasm)" || "$(ic-wasm --version)" != "ic-wasm 0.8.5" ]]
89+
# then
90+
# echo "could not find ic-wasm 0.8.5"
91+
# echo "ic-wasm version 0.8.5 is needed, please run the following command:"
92+
# echo " cargo install ic-wasm --version 0.8.5"
93+
# exit 1
94+
# fi
9595

9696
# Check for exact node version
9797
if [[ "$(node --version)" != "v$(cat .node-version)" ]]

src/internet_identity/internet_identity.did

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ type Aud = text;
366366
type JWT = text;
367367
type Salt = blob;
368368

369+
type OpenIdEmailVerification = variant {
370+
Google;
371+
Microsoft;
372+
};
373+
369374
type OpenIdConfig = record {
370375
name : text;
371376
logo : text;
@@ -375,6 +380,7 @@ type OpenIdConfig = record {
375380
auth_uri : text;
376381
auth_scope : vec text;
377382
fedcm_uri : opt text;
383+
email_verification : opt OpenIdEmailVerification;
378384
};
379385

380386
type OpenIdCredentialKey = record { Iss; Sub };

0 commit comments

Comments
 (0)