Skip to main content

Basic Implementation Using the Auth API

This page describes sign-in, additional challenges, token refresh, and sign-out in the sample application.
For an overview, see the Auth API implementation guide.

Endpoints such as /challenge below belong to the sample backend; they are separate from the SaaSus Platform Auth API endpoints.

Start sign-in​

The login form accepts an email address or SaaSus Platform login ID and a password.
A login ID can be sent directly without a tenant ID or conversion to an email address.

The frontend generates the SRP public value and sends it with the identifier to /challenge without sending the password.
The backend calls SignIn using the USER_SRP_AUTH flow and returns the PASSWORD_VERIFIER challenge values.

const srpHelper = new SRPAuthHelper();
const srpA = srpHelper.getLargeAValue();
const challengeResponse = await apiClient.post('/challenge', {
username: account, // Email address or login ID
srp_a: srpA,
});

Generate and verify the signature​

The frontend generates a signature from the password and challenge values, then sends it to /verify.
If a remembered device exists, it also sends the device key.

const challenge = challengeResponse.data;
const key = srpHelper.getPasswordAuthenticationKey(
challenge.pool_name, challenge.username, password,
challenge.srp_b, challenge.salt
);
const timestamp = getNowString();
const signature = srpHelper.getSignature(
challenge.pool_name, challenge.username, challenge.secret_block, timestamp, key
);
const result = await apiClient.post('/verify', {
username: challenge.username,
signature,
timestamp,
secret_block: challenge.secret_block,
session: challenge.session || '',
device_key: getDevice(challenge.username)?.key,
});

The backend sends the signature in a PASSWORD_VERIFIER response to RespondToSignInChallenge.
When a response includes a session, pass it to the next challenge response.
The result may contain tokens or another challenge.

Respond to additional challenges​

For NEW_PASSWORD_REQUIRED, the frontend sends the new password and session to /new-password.
The backend passes the new password to RespondToSignInChallenge.
Check the result because another challenge, such as MFA, can follow a password change.

For SOFTWARE_TOKEN_MFA or EMAIL_OTP, send the code and session to /mfa.
The backend uses SOFTWARE_TOKEN_MFA_CODE or EMAIL_OTP_CODE, respectively.

After sign-in, the user can configure or disable authenticator-app or email MFA.
The sample allows email MFA for email-authenticated users when the email domain and sending configuration are complete; it also disables the option when those settings cannot be confirmed.
If the user loses access to the MFA method, an administrator can disable MFA in the SaaS Operations Console.

Remembered devices​

After authentication, the frontend receives a device key and group key, then generates a device password and verifier.
The backend passes the verifier to ConfirmDevice and uses UpdateDeviceStatus when needed.
The device password is stored in browser localStorage and is not sent to the backend.

On a later sign-in, the frontend sends the device key and, if it receives DEVICE_SRP_AUTH, generates an SRP signature using the saved device information.
The backend responds to the device challenges using RespondToSignInChallenge.
When device remembering is configured as user opt-in, the login screen displays a checkbox.

Refresh and sign out​

After authentication, the backend stores the tokens in HttpOnly cookies.
If a protected API returns 401, the frontend tries /refresh once and retries the original request.
If refresh fails, the user needs to sign in again.

On sign-out, /logout calls RevokeToken and deletes the cookies after a successful response.
See Authentication security and policy for token handling and CSRF protection.