@@ -4,8 +4,8 @@ use crate::anchor_management::registration::captcha::{
44use crate :: anchor_management:: registration:: rate_limit:: process_rate_limit;
55use crate :: anchor_management:: registration:: Base64 ;
66use crate :: anchor_management:: {
7- activity_bookkeeping , add_openid_credential_skip_checks , check_openid_credential_is_unique ,
8- post_operation_bookkeeping, set_name,
7+ self , activity_bookkeeping , add_openid_credential_skip_checks ,
8+ check_openid_credential_is_unique , post_operation_bookkeeping, set_name,
99} ;
1010use crate :: state:: flow_states:: RegistrationFlowState ;
1111use crate :: storage:: anchor:: { Anchor , Device } ;
@@ -17,10 +17,10 @@ use ic_cdk::caller;
1717use ic_stable_structures:: Memory ;
1818use internet_identity_interface:: archive:: types:: { DeviceDataWithoutAlias , Operation } ;
1919use internet_identity_interface:: internet_identity:: types:: {
20- AuthnMethod , AuthorizationKey , CaptchaTrigger , CheckCaptchaArg , CheckCaptchaError ,
21- CreateIdentityData , DeviceData , DeviceWithUsage , IdRegFinishArg , IdRegFinishError ,
22- IdRegFinishResult , IdRegNextStepResult , IdRegStartError , IdentityNumber , OpenIDRegFinishArg ,
23- RegistrationFlowNextStep , StaticCaptchaTrigger ,
20+ AuthnMethod , AuthnMethodData , AuthorizationKey , CaptchaTrigger , CheckCaptchaArg ,
21+ CheckCaptchaError , CreateIdentityData , DeviceData , DeviceWithUsage , IdRegFinishArg ,
22+ IdRegFinishError , IdRegFinishResult , IdRegNextStepResult , IdRegStartError , IdentityNumber ,
23+ OpenIDRegFinishArg , RegistrationFlowNextStep , StaticCaptchaTrigger ,
2424} ;
2525
2626impl RegistrationFlowState {
@@ -236,18 +236,6 @@ fn validate_identity_data<M: Memory + Clone>(
236236) -> Result < ValidatedCreateIdentityData , IdRegFinishError > {
237237 match & arg {
238238 CreateIdentityData :: PubkeyAuthn ( arg) => {
239- // Enforce global uniqueness of passkey pubkeys across all anchors.
240- if let AuthnMethod :: WebAuthn ( webauthn) = & arg. authn_method . authn_method {
241- if storage
242- . lookup_anchor_with_passkey_pubkey ( & webauthn. pubkey )
243- . is_some ( )
244- {
245- return Err ( IdRegFinishError :: InvalidAuthnMethod (
246- "passkey with this public key is already used" . to_string ( ) ,
247- ) ) ;
248- }
249- }
250-
251239 Ok ( ValidatedCreateIdentityData :: PubkeyAuthn ( arg. clone ( ) ) )
252240 }
253241 CreateIdentityData :: OpenID ( openid_registration_data) => {
@@ -323,6 +311,20 @@ fn apply_identity_data(
323311}
324312
325313fn create_identity ( arg : & CreateIdentityData , now : u64 ) -> Result < IdentityNumber , IdRegFinishError > {
314+ // Enforce global uniqueness of passkey pubkeys across all anchors.
315+ if let CreateIdentityData :: PubkeyAuthn ( IdRegFinishArg {
316+ authn_method :
317+ AuthnMethodData {
318+ authn_method : AuthnMethod :: WebAuthn ( webauthn) ,
319+ ..
320+ } ,
321+ ..
322+ } ) = & arg
323+ {
324+ anchor_management:: check_passkey_pubkey_is_not_used ( & webauthn. pubkey )
325+ . map_err ( |err| IdRegFinishError :: InvalidAuthnMethod ( err) ) ?;
326+ }
327+
326328 let ( identity_number, operation) = state:: storage_borrow_mut ( |storage| {
327329 let arg = validate_identity_data ( storage, arg) ?;
328330
0 commit comments