Single Sign On with Multi Factor Authentication using Cypress 10

Automate SSO with MFA using Cypress 10

With Cypress 10, the cy.origin module can be used to visit multiple domains in the same test, which facilitates SSO automation. The Cypress OTP library can generate codes for MFA, and the combination of both can automate SSO with Office 365 with MFA enabled.

What is SSO (Single Sing-On)

With single sign-on (SSO), users may securely log in to a number of different applications and websites with just one set of credentials.

 What is MFA  (Multi-Factor Authentication)

A robust identity and access management (IAM) policy must incorporate MFA as a crucial component. MFA requires one or more additional verification methods besides a username and password, reducing the risk of successful cyberattacks.

What are the test requirements?

1. Cypress 10 installed. 2. The secret key for Office 365 account. 3. And one npm package. To get more solution visit our below link.

How installation and use in Cypress 10

You can use above npm command to install - npm i cypress-otp

How to Implement in Test

Create a file named 'beforeafter.js' in the Cypress folder and paste the code for creating a session. The code is a custom command called in the command.js file which passes email, password and secret key as parameters. The session is restored to quickly authenticate and log in to the application.

Conclusion

We are successfully able to automate login to the application through SSO and automate MFA and reduce the login time using a session in Cypress. Here is a link to another good read around the same topic.