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:
23
server/authenticators/providers/providers.go
Normal file
23
server/authenticators/providers/providers.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package providers
|
||||
|
||||
import "context"
|
||||
|
||||
// AuthenticatorConfig defines authenticator config
|
||||
type AuthenticatorConfig struct {
|
||||
// ScannerImage is the base64 of QR code image
|
||||
ScannerImage string
|
||||
// Secrets is the secret key
|
||||
Secret string
|
||||
// RecoveryCode is the secret key
|
||||
RecoveryCodes []string
|
||||
}
|
||||
|
||||
// Provider defines authenticators provider
|
||||
type Provider interface {
|
||||
// Generate totp: to generate totp, store secret into db and returns base64 of QR code image
|
||||
Generate(ctx context.Context, id string) (*AuthenticatorConfig, error)
|
||||
// Validate totp: user passcode with secret stored in our db
|
||||
Validate(ctx context.Context, passcode string, id string) (bool, error)
|
||||
// RecoveryCode totp: gives a recovery code for first time user
|
||||
RecoveryCode(ctx context.Context, id string) (*string, error)
|
||||
}
|
Reference in New Issue
Block a user