Since AWS Cognito does not currently support passwordless authentication, you need to implement a workaround with a random password stored externally. You can implement the authentication flow as follows.
- After registering the user (also indicate the mobile phone number and make it mandatory), save the mobile phone number, username and password also in Dynamodb, encrypted using AWS KMS (For added security).
- MFA , , (In frontend), (Passthrough) MFA , AWS Cognito SDK ( ).
- ( MFA) SMS , AWS SNS .
, MFA . .
var userData = {
Username : 'username',
Pool : userPool
};
cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
var authenticationData = {
Username : 'username',
Password : 'password',
};
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
alert('authentication successful!')
},
onFailure: function(err) {
alert(err);
},
mfaRequired: function(codeDeliveryDetails) {
var verificationCode = prompt('Please input verification code' ,'');
cognitoUser.sendMFACode(verificationCode, this);
}
});
: MFA MFA, .