feat: add totp login API (#416)

* fix:
* removed hasReversedValue in playground

* feat:
* added totp methods in db's providers
* adding totp in login method

* feat:
* added toggle in dashboard
* fixing issue with env set

* feat:
* integrated totp

* feat:
* encrypted userid
* added totp_verified column in user table
* started test for totp

* feat:
* test cases totp

* test-cases:
* completed test cases
* tested for all dbs

* fixes:
* return variable to snake case
* import refactoring

* feat:
* created seperate folder for authenticator with totp subfolder
* refactored code
* created new table for authenticators
* added recovery code for totp

* feat:
* adding functions to different db providers

* feat:
* added authenticators method for all db

* feat:
* added logic for updating mfa in user_profile update

* fix:
* merge conflict

* fix:
* resolved mongodb, dynamodb and arangodb test case bug
* added new condition for checking first time totp user or not

* feat:
* changes in all respective db with authenticator

* fix:
* PR suggested changes

* fix(cassandra): list users

* Update verify otp

* fix totp login api

---------

Co-authored-by: lemonScaletech <anand.panigrahi@scaletech.xyz>
This commit is contained in:
Lakhan Samani
2023-11-16 18:30:54 +05:30
committed by GitHub
parent d8cd965004
commit fe4c693324
57 changed files with 4321 additions and 1111 deletions

View File

@@ -26,14 +26,18 @@ type AdminSignupInput struct {
}
type AuthResponse struct {
Message string `json:"message"`
ShouldShowEmailOtpScreen *bool `json:"should_show_email_otp_screen,omitempty"`
ShouldShowMobileOtpScreen *bool `json:"should_show_mobile_otp_screen,omitempty"`
AccessToken *string `json:"access_token,omitempty"`
IDToken *string `json:"id_token,omitempty"`
RefreshToken *string `json:"refresh_token,omitempty"`
ExpiresIn *int64 `json:"expires_in,omitempty"`
User *User `json:"user,omitempty"`
Message string `json:"message"`
ShouldShowEmailOtpScreen *bool `json:"should_show_email_otp_screen,omitempty"`
ShouldShowMobileOtpScreen *bool `json:"should_show_mobile_otp_screen,omitempty"`
ShouldShowTotpScreen *bool `json:"should_show_totp_screen,omitempty"`
AccessToken *string `json:"access_token,omitempty"`
IDToken *string `json:"id_token,omitempty"`
RefreshToken *string `json:"refresh_token,omitempty"`
ExpiresIn *int64 `json:"expires_in,omitempty"`
User *User `json:"user,omitempty"`
AuthenticatorScannerImage *string `json:"authenticator_scanner_image,omitempty"`
AuthenticatorSecret *string `json:"authenticator_secret,omitempty"`
AuthenticatorRecoveryCodes []*string `json:"authenticator_recovery_codes,omitempty"`
}
type DeleteEmailTemplateRequest struct {
@@ -122,6 +126,8 @@ type Env struct {
DefaultAuthorizeResponseType *string `json:"DEFAULT_AUTHORIZE_RESPONSE_TYPE,omitempty"`
DefaultAuthorizeResponseMode *string `json:"DEFAULT_AUTHORIZE_RESPONSE_MODE,omitempty"`
DisablePlayground bool `json:"DISABLE_PLAYGROUND"`
DisableMailOtpLogin bool `json:"DISABLE_MAIL_OTP_LOGIN"`
DisableTotpLogin bool `json:"DISABLE_TOTP_LOGIN"`
}
type Error struct {
@@ -382,6 +388,8 @@ type UpdateEnvInput struct {
DefaultAuthorizeResponseType *string `json:"DEFAULT_AUTHORIZE_RESPONSE_TYPE,omitempty"`
DefaultAuthorizeResponseMode *string `json:"DEFAULT_AUTHORIZE_RESPONSE_MODE,omitempty"`
DisablePlayground *bool `json:"DISABLE_PLAYGROUND,omitempty"`
DisableMailOtpLogin *bool `json:"DISABLE_MAIL_OTP_LOGIN,omitempty"`
DisableTotpLogin *bool `json:"DISABLE_TOTP_LOGIN,omitempty"`
}
type UpdateProfileInput struct {
@@ -502,6 +510,7 @@ type VerifyOTPRequest struct {
Email *string `json:"email,omitempty"`
PhoneNumber *string `json:"phone_number,omitempty"`
Otp string `json:"otp"`
Totp *bool `json:"totp,omitempty"`
State *string `json:"state,omitempty"`
}