Configuring Email OTP
This section provides the instructions to configure multi-factor authentication (MFA) using Email One Time Password (Email OTP) in WSO2 Identity Server (WSO2 IS). The Email OTP enables a one-time password (OTP) to be used at the second step of MFA.
Follow the instructions in the sections below to configure MFA using Email OTP:
Before you begin!
To ensure you get the full understanding of configuring Email OTP with WSO2 IS, the sample Travelocity application is used in this use case. Therefore, make sure to download the samples before you begin.
The samples run on the Apache Tomcat server and are written based on Servlet 3.0. Therefore, download Tomcat 7.x from here.
Install Apache Maven to build the samples. For more information, see Installation Prerequisites.
Configure the email OTP provider
You can use WSO2 Identity Server as the email OTP provider or you can configure Gmail or SendGrid as the email OTP provider using Gmail or SendGrid APIs. Follow the instructions in one of these sections to set up the email OTP provider.
Configure WSO2 IS as the email OTP provider
Follow the steps below to configure WSO2 IS to send emails once the Email OTP is enabled.
Alternatively, you can configure Gmail as the email OTP provider by following the instructions given in this section.
Configure Gmail as the email OTP provider
You can send the One Time Password (OTP) using Gmail APIs or using SendGrid. Follow the steps given below to configure Gmail APIs as the mechanism to send the OTP.
Alternatively, you can configure WSO2 Identity Server as the email OTP provider by following the instructions given in this section.
Create a Google account at https://gmail.com.
Got to https://console.developers.google.com and click ENABLE APIS AND SERVICES.
Search for Gmail API and click on it.
Click Enable to enable the Gmail APIs.
Click Credentials and click Create to create a new project.
Click Credentials and click the Create credentials drop-down.
Select OAuth client ID option.
Click Configure consent screen.
Enter the Product name that needs to be shown to users, enter values to any other fields you prefer to update, and click Save.
Select the Web application option.
Enterhttps://localhost:9443/commonauthas the Authorize redirect URIs text-box, and click Create.
The
client IDand theclient secretare displayed.
Copy the client ID and secret and keep it in a safe place as you require it for the next step.Copy the URL below and replace the
<ENTER_CLIENT_ID>tag with the generatedClient ID. This is required to generate the authorization code.Paste the updated URL into your browser.
Select the preferred Gmail account with which you wish to proceed.
Click Allow.
Obtain the
authorization codeusing a SAML tracer on your browser.
To generate the access token, copy the following cURL command and replace the following place holders:
<CLIENT-ID>: Replace this with theclient IDobtained in Step 10 above.<CLIENT_SECRET>: Replace this with theclient secretobtained in Step 10 above.<AUTHORIZATION_CODE>: Replace this with the authorization code obtained in Step 12 above.
Paste the updated cURL command in your terminal to generate the OAuth2 access token, token validity period, and the refresh token.
Update the following configurations under the
<AuthenticatorConfigs>section in the<IS_HOME>/repository/conf/identity/application-authentication.xmlfile.
Deploy the travelocity.com sample
Now that you have set up WSO2 IS or Gmail as the Email OTP provider, follow the steps below to deploy the travelocity.com sample application, which you can use to try out the Email OTP scenario.
Configure the Identity Provider
Follow the steps below to add an identity provider:
Click Add under Main > Identity > Identity Providers.
Provide a suitable name for the identity provider.
Expand the EmailOTPAuthenticator Configuration under Federated Authenticators.
Select the Enable and Default check boxes.
Click Register.
You have now added the identity provider.
Configure the Service Provider
Follow the steps below add a service provider:
Return to the Management Console home screen.
Click Add under Add under Main > Identity > Service Providers .
Enter
travelocity.comas the Service Provider Name.Click Register.
Expand SAML2 Web SSO Configuration under Inbound Authentication Configuration.
Click Configure.
Now set the configuration as follows:
Issuer:
travelocity.comAssertion Consumer URL:
http://localhost:8080/travelocity.com/home.jspSelect the following check-boxes: Enable Response Signing, Enable Single Logout, Enable Attribute Profile, and Include Attributes in the Response Always.
Click Update to save the changes. Now you will be sent back to the Service Providers page.
Go to Claim Configuration and select the http://wso2.org/claims/emailaddress claim.
Go to Local and Outbound Authentication Configuration section.
Select the Advanced configuration radio button option.
Creating the first authentication step:
Click Add Authentication Step.
Click Add Authenticator that is under Local Authenticators of Step 1 to add the basic authentication as the first step.
Adding basic authentication as a first step ensures that the first step of authentication will be done using the user's credentials that are configured with the WSO2 Identity Server
Creating the second authentication step:
Click Add Authentication Step.
Click Add Authenticator that is under Federated Authenticators of Step 2 to add the SMSOTP identity provider you created as the second step.
SMSOTP is a second step that adds another layer of authentication and security.
Click Update.
You have now added and configured the service provider.
Update the email address of the user
Follow the steps given below to update the user's email address.
Return to the WSO2 Identity Server Management Console home screen.
Click List under Add under Main > Identity > Users and Roles.
Click Users.
Click User Profile under Admin.
Update the email address.
Click Update.
Configure the user claims
Follow the steps below to map the user claims:
For more information about claims, see Adding Claim Mapping.
Click Add under Main > Identity > Claims.
Click Add Local Claim.
Select the Dialect from the drop down provided and enter the required information.
Add the following:
Claim URI:
http://wso2.org/claims/identity/emailotp_disabledDisplay Name:
DisableEmailOTPDescription:
DisableEmailOTPMapped Attribute (s):
titleSupported by Default: checked
Click Add.
Test the sample
To test the sample, go to the following URL: http://localhost:8080/travelocity.com
Click the link to log in with SAML from WSO2 Identity Server.
The basic authentication page appears. Use your WSO2 Identity Server credentials.
You receive a token to your email account. Enter the code to authenticate. If the authentication is successful, you are taken to the home page of the travelocity.com app.
What's next?
Want to see more federated authenticators? See, Configuring Federated Authentication
Try out enabling multi factor authentication using the SMSOTP feature of WSO2 IS.