-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change registration on API v2 to flow with 3 steps
The registration for new identities using API v2 is now split into 3 different steps: 1. start a flow, providing a principal to track progress on that flow 2. solve captcha 3. submit authn_method to tie the identity to This PR is a preparation to making the step 2 dynamically remove step 2 on low load.
- Loading branch information
1 parent
6bdccc8
commit d7503f1
Showing
14 changed files
with
817 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
diff --git a/src/internet_identity/internet_identity.did b/src/internet_identity/internet_identity.did | ||
index 500ef4d6..eb75b075 100644 | ||
--- a/src/internet_identity/internet_identity.did | ||
+++ b/src/internet_identity/internet_identity.did | ||
@@ -435,6 +435,17 @@ type IdentityInfoError = variant { | ||
InternalCanisterError: text; | ||
}; | ||
|
||
+ | ||
+ | ||
+type IdentityRegisterError = variant { | ||
+ // No more registrations are possible in this instance of the II service canister. | ||
+ CanisterFull; | ||
+ // The captcha check was not successful. | ||
+ BadCaptcha; | ||
+ // The metadata of the provided authentication method contains invalid entries. | ||
+ InvalidMetadata: text; | ||
+}; | ||
+ | ||
type AuthnMethodAddError = variant { | ||
InvalidMetadata: text; | ||
}; | ||
@@ -521,72 +532,6 @@ type SignedIdAlias = record { | ||
id_dapp : principal; | ||
}; | ||
|
||
-type IdRegNextStepResult = record { | ||
- // The next step in the registration flow | ||
- next_step: RegistrationFlowNextStep; | ||
-}; | ||
- | ||
-type IdRegStartError = variant { | ||
- // The method was called anonymously, which is not supported. | ||
- InvalidCaller; | ||
- // Too many registrations. Please try again later. | ||
- RateLimitExceeded; | ||
- // A registration flow is already in progress. | ||
- AlreadyInProgress; | ||
-}; | ||
- | ||
-// The next step in the registration flow: | ||
-// - CheckCaptcha: supply the solution to the captcha using `check_captcha` | ||
-// - Finish: finish the registration using `identity_registration_finish` | ||
-type RegistrationFlowNextStep = variant { | ||
- // Supply the captcha solution using check_captcha | ||
- CheckCaptcha: record { | ||
- captcha_png_base64: text; | ||
- }; | ||
- // Finish the registration using identity_registration_finish | ||
- Finish; | ||
-}; | ||
- | ||
-type CheckCaptchaArg = record { | ||
- solution : text; | ||
-}; | ||
- | ||
-type CheckCaptchaError = variant { | ||
- // The supplied solution was wrong. Try again with the new captcha. | ||
- WrongSolution: record { | ||
- new_captcha_png_base64: text; | ||
- }; | ||
- // This call is unexpected, see next_step. | ||
- UnexpectedCall: record { | ||
- next_step: RegistrationFlowNextStep; | ||
- }; | ||
- // No registration flow ongoing for the caller. | ||
- NoRegistrationFlow; | ||
-}; | ||
- | ||
-type IdRegFinishArg = record { | ||
- authn_method: AuthnMethodData; | ||
-}; | ||
- | ||
-type IdRegFinishResult = record { | ||
- identity_number: nat64; | ||
-}; | ||
- | ||
-type IdRegFinishError = variant { | ||
- // The configured maximum number of identities has been reached. | ||
- IdentityLimitReached; | ||
- // This call is unexpected, see next_step. | ||
- UnexpectedCall: record { | ||
- next_step: RegistrationFlowNextStep; | ||
- }; | ||
- // No registration flow ongoing for the caller. | ||
- NoRegistrationFlow; | ||
- // The supplied authn_method is not valid. | ||
- InvalidAuthnMethod: text; | ||
- // Error while persisting the new identity. | ||
- StorageError: text; | ||
-}; | ||
- | ||
service : (opt InternetIdentityInit) -> { | ||
// Legacy identity management API | ||
// ============================== | ||
@@ -613,17 +558,16 @@ service : (opt InternetIdentityInit) -> { | ||
|
||
// V2 Identity Management API | ||
// ========================== | ||
- // WARNING: The following methods are experimental and may ch 0ange in the future. | ||
- | ||
- // Starts the identity registration flow to create a new identity. | ||
- identity_registration_start: () -> (variant {Ok: IdRegNextStepResult; Err: IdRegStartError;}); | ||
+ // WARNING: The following methods are experimental and may change in the future. | ||
|
||
- // Check the captcha challenge | ||
- // If successful, the registration can be finished with `identity_registration_finish`. | ||
- check_captcha: (CheckCaptchaArg) -> (variant {Ok: IdRegNextStepResult; Err: CheckCaptchaError;}); | ||
+ // Creates a new captcha. The solution needs to be submitted using the | ||
+ // `identity_register` call. | ||
+ captcha_create: () -> (variant {Ok: Challenge; Err;}); | ||
|
||
- // Starts the identity registration flow to create a new identity. | ||
- identity_registration_finish: (IdRegFinishArg) -> (variant {Ok: IdRegFinishResult; Err: IdRegFinishError;}); | ||
+ // Registers a new identity with the given authn_method. | ||
+ // A valid captcha solution to a previously generated captcha (using create_captcha) must be provided. | ||
+ // The sender needs to match the supplied authn_method. | ||
+ identity_register: (AuthnMethodData, CaptchaResult, opt principal) -> (variant {Ok: IdentityNumber; Err: IdentityRegisterError;}); | ||
|
||
// Returns information about the authentication methods of the identity with the given number. | ||
// Only returns the minimal information required for authentication without exposing any metadata such as aliases. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.