new MFAAdapter(options)
Parse Server Configuration
To configure Parse Server for MFA, use the following structure:
{
auth: {
mfa: {
options: ["SMS", "TOTP"],
digits: 6,
period: 30,
algorithm: "SHA1",
sendSMS: (token, mobile) => {
// Send the SMS using your preferred SMS provider.
console.log(`Sending SMS to ${mobile} with token: ${token}`);
}
}
}
}
MFA Methods
SMS:
- Requires a valid mobile number.
- Sends a one-time password (OTP) via SMS for login or verification.
- Uses the
sendSMS
callback for sending the OTP.
TOTP:
- Requires a secret key for setup.
- Validates the user's OTP against a time-based one-time password (TOTP) generated using the secret key.
- Supports configurable digits, period, and algorithm for TOTP generation.
MFA Payload
The adapter requires the following authData
fields:
- For SMS-based MFA:
mobile
: The user's mobile number (required for setup).token
: The OTP provided by the user for login or verification.
- For TOTP-based MFA:
secret
: The TOTP secret key for the user (required for setup).token
: The OTP provided by the user for login or verification.
Example Payloads
SMS Setup Payload
{
"mobile": "+1234567890"
}
TOTP Setup Payload
{
"secret": "BASE32ENCODEDSECRET",
"token": "123456"
}
Login Payload
{
"token": "123456"
}
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | Object | The adapter options. Properties
|