Skip to content

Commit 6a0e874

Browse files
committed
Add OpenIdEmailVerification enum to OpenIdConfig
1 parent d091a90 commit 6a0e874

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

src/internet_identity/internet_identity.did

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

367+
type OpenIdEmailVerification = variant {
368+
Google;
369+
Microsoft;
370+
};
371+
367372
type OpenIdConfig = record {
368373
name : text;
369374
logo : text;
@@ -373,6 +378,7 @@ type OpenIdConfig = record {
373378
auth_uri : text;
374379
auth_scope : vec text;
375380
fedcm_uri : opt text;
381+
email_verification : opt OpenIdEmailVerification;
376382
};
377383

378384
type OpenIdCredentialKey = record { Iss; Sub };

src/internet_identity/src/openid.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use internet_identity_interface::internet_identity::types::openid::{
1212
OpenIdCredentialAddError, OpenIdDelegationError,
1313
};
1414
use internet_identity_interface::internet_identity::types::{
15-
AnchorNumber, Delegation, EmailVerification, IdRegFinishError, MetadataEntryV2, OpenIdConfig,
16-
PublicKey, SessionKey, SignedDelegation, Timestamp, UserKey,
15+
AnchorNumber, Delegation, IdRegFinishError, MetadataEntryV2, OpenIdConfig,
16+
OpenIdEmailVerification, PublicKey, SessionKey, SignedDelegation, Timestamp, UserKey,
1717
};
1818
use serde_bytes::ByteBuf;
1919
use sha2::{Digest, Sha256};
@@ -184,7 +184,7 @@ impl OpenIdCredential {
184184
pub trait OpenIdProvider {
185185
fn issuer(&self) -> String;
186186

187-
fn email_verification(&self) -> Option<EmailVerification>;
187+
fn email_verification(&self) -> Option<OpenIdEmailVerification>;
188188

189189
/// Verify JWT and bound nonce with salt, return `OpenIdCredential` if successful
190190
///
@@ -289,12 +289,12 @@ pub fn get_all_claims(claims_bytes: &[u8], keys: Vec<String>) -> Vec<(String, St
289289

290290
/// Get the verified email from metadata if it passes the provider's verification requirements.
291291
pub fn get_verified_email(
292-
verification: &EmailVerification,
292+
verification: &OpenIdEmailVerification,
293293
metadata: &HashMap<String, MetadataEntryV2>,
294294
) -> Option<String> {
295295
match verification {
296-
EmailVerification::Google => get_google_verified_email(metadata),
297-
EmailVerification::Microsoft => get_microsoft_verified_email(metadata),
296+
OpenIdEmailVerification::Google => get_google_verified_email(metadata),
297+
OpenIdEmailVerification::Microsoft => get_microsoft_verified_email(metadata),
298298
}
299299
}
300300

@@ -401,7 +401,7 @@ impl OpenIdProvider for ExampleProvider {
401401
"https://example.com".into()
402402
}
403403

404-
fn email_verification(&self) -> Option<EmailVerification> {
404+
fn email_verification(&self) -> Option<OpenIdEmailVerification> {
405405
None
406406
}
407407

@@ -603,7 +603,7 @@ impl OpenIdProvider for ExamplePlaceholderProvider {
603603
"https://login.microsoftonline.com/{tid}/v2.0".into()
604604
}
605605

606-
fn email_verification(&self) -> Option<EmailVerification> {
606+
fn email_verification(&self) -> Option<OpenIdEmailVerification> {
607607
None
608608
}
609609

src/internet_identity/src/openid/generic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use identity_jose::jws::{
1919
VerificationInput,
2020
};
2121
use internet_identity_interface::internet_identity::types::{
22-
EmailVerification, MetadataEntryV2, OpenIdConfig,
22+
MetadataEntryV2, OpenIdConfig, OpenIdEmailVerification,
2323
};
2424
use rsa::{Pkcs1v15Sign, RsaPublicKey};
2525
use serde::Serialize;
@@ -103,15 +103,15 @@ pub struct Provider {
103103
client_id: String,
104104
issuer: String,
105105
certs: Rc<RefCell<Vec<Jwk>>>,
106-
email_verification: Option<EmailVerification>,
106+
email_verification: Option<OpenIdEmailVerification>,
107107
}
108108

109109
impl OpenIdProvider for Provider {
110110
fn issuer(&self) -> String {
111111
self.issuer.clone()
112112
}
113113

114-
fn email_verification(&self) -> Option<EmailVerification> {
114+
fn email_verification(&self) -> Option<OpenIdEmailVerification> {
115115
self.email_verification.clone()
116116
}
117117

src/internet_identity_interface/src/internet_identity/types.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,8 @@ pub enum DeployArchiveResult {
356356
}
357357

358358
#[derive(Clone, Debug, CandidType, Deserialize, Eq, PartialEq)]
359-
pub enum EmailVerification {
360-
#[serde(rename = "google")]
359+
pub enum OpenIdEmailVerification {
361360
Google,
362-
#[serde(rename = "microsoft")]
363361
Microsoft,
364362
}
365363

@@ -373,7 +371,7 @@ pub struct OpenIdConfig {
373371
pub auth_uri: String,
374372
pub auth_scope: Vec<String>,
375373
pub fedcm_uri: Option<String>,
376-
pub email_verification: Option<EmailVerification>,
374+
pub email_verification: Option<OpenIdEmailVerification>,
377375
}
378376

379377
pub enum AuthorizationKey {

0 commit comments

Comments
 (0)