This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Configuring a User Preferred Notification Channel
The steps given below guide you through configuring WSO2 Identity Server to use a user-preferred notification channel (i.e., EMAIL or SMS) to send the notification for self-registration and account confirmation purposes.
Before you begin
To learn more about self-registration and account confirmation APIs, see Extending User Self Registration and Account Confirmation.
Configure the following email settings in the <
IS_HOME>/repository/conf/output-event-adapters.xml
file.mail.smtp.from
Provide the email address of the SMTP account. mail.smtp.user
Provide the username of the SMTP account. mail.smtp.password
Provide the password of the SMTP account. <adapterConfig type="email"> <!-- Comment mail.smtp.user and mail.smtp.password properties to support connecting SMTP servers which use trust based authentication rather username/password authentication --> <property key="mail.smtp.from">abcd@gmail.com</property> <property key="mail.smtp.user">abcd</property> <property key="mail.smtp.password">xxxx</property> <property key="mail.smtp.host">smtp.gmail.com</property> <property key="mail.smtp.port">587</property> <property key="mail.smtp.starttls.enable">true</property> <property key="mail.smtp.auth">true</property> <!-- Thread Pool Related Properties --> <property key="minThread">8</property> <property key="maxThread">100</property> <property key="keepAliveTimeInMillis">20000</property> <property key="jobQueueSize">10000</property> </adapterConfig>
The email templates for notifications are stored in the
email-admin-config.xml
file found in the<IS_HOME>/repository/conf/email
folder. Add the SMS templates to the .xml file with ‘sms’ prefix.
For example, this is a sample of an email template configuration.type="accountConfirmation" display="AccountConfirmation
Add a new template with the following name format for SMS notifications.
type="smsAccountconfirmation" display="smsAccountconfirmation
Sample SMS notification template<configuration type="smsaccountconfirmation" display="smsaccountconfirmation" locale="en_US" emailContentType="text/html"> <subject>WSO2 - Self Registration OTP</subject> <body>Your OTP is : {{confirmation-code}}</body> <footer>---</footer> </configuration>
If you are using a WSO2 Identity Server 5.7.0 WUM updated pack, SMS notifications are managed using the registry and are no longer managed using the
email-admin-config.xml
file. For instructions, see Managing SMS Notification Templates Using the Registry.Create a new stream and add it to the
<IS_HOME>/repository/deployment/server/eventstreams
folder. A sample stream is given below.Sample stream{"name": "id_gov_sms_notify_stream","version": "1.0.0" }
Create a new publisher and add it to the
<IS_HOME>/repository/deployment/server/eventpublishers
folder.
For more information, see HTTP Event Publisher in the WSO2 Data Analytics Server documentation.Sample publisher<?xml version="1.0" encoding="UTF-8"?> <eventPublisher name="HTTPOutputEventAdapter" processing="enable" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> <from streamName="id_gov_sms_notify_stream" version="1.0.0"/> <mapping customMapping="enable" type="json"> <inline> {"api_key"="<api_key>", "api_secret"="<api secret>", "from"="NEXMO", "to"={{mobile}}, "text"={{body}} } </inline> </mapping> <to eventAdapterType="http"> <property name="http.client.method">httpPost</property> <property name="http.url">https://rest.nexmo.com/sms/json</property> </to> </eventPublisher>
Configure the
identity-event.properties
file found in the<IS_HOME>/repository/conf/identity
folder to subscribe the event handler to trigger notifications.Sample notification handler configurationmodule.name.13=default.notification.sender default.notification.sender.subscription.1=TRIGGER_SMS_NOTIFICATION default.notification.sender.subscription.TRIGGER_SMS_NOTIFICATION.stream=id_gov_sms_notify_stream:1.0.0 default.notification.sender.subscription.TRIGGER_SMS_NOTIFICATION.claim.mobile=http://wso2.org/claims/mobile
Add the following configurations to the
identity.xml
file found in the<IS_HOME> /repository/conf/identity
folder within the<server>
tags to resolve the notification channel. This configuration only affects the user self-registration scenario.<Notification> <DefaultNotificationChannel>EMAIL</DefaultNotificationChannel> <ResolveNotificationChannels> <Enable>true</Enable> </ResolveNotificationChannels> </Notification>
Property Description Default Value DefaultNotificationChannel
Determines the default notification channel for the server. Currently, WSO2 IS supports EMAIL and SMS as communication channels. Providing any other value will result in errors.
These configurations are case sensitive. Always use uppercase characters.
EMAIL ResolveNotificationChannels
Enables notification channel resolving according to the notification channel selecting criteria. Disabling the configuration will resolve the notification channel to the server default notification channel. FALSE Add the following configurations to the
identity.xml
file found in the<IS_HOME>/repository/conf/identity
folder inside the<SelfRegistration>
tags.<RegisterWithVerifiedChannels>true</RegisterWithVerifiedChannels> <API> <EnableDetailedResponseBody>True</EnableDetailedResponseBody> </API>
Property Description Default Value RegisterWithVerifiedChannels
Enables self-registration after pre-confirmation of the user account, with verified claims. If the property is not enabled, account confirmation is needed even though the account is pre-confirmed. FALSE EnableDetailedResponseBody
Enables detailed API responses. FALSE - Restart the server to apply configurations.
Configuring the management console
- Start WSO2 Identity Server and access the management console.
- Click List under Main >Claims and enable the
Email Verified
andPhone Verified
claims for the default profile by selecting the "Supported by default" checkbox for the relevant claim. Click Add under Main > Claims and add the following identity claim to track the user preferred notification channel.
DO NOT change the given claim. A different claim will not be supported by the APIs.
- Once you have added the claim, click List under Main > Claims and enable the newly added claim by selecting the "Supported by default" checkbox.
- Navigate to Main > Identity Providers > Resident and expand the Account Management Policies section.
Expand the User Self Registration section and configure the following properties as required.
Field Description Enable Self User Registration Enable self-registration. Enable Account Lock On Creation Enabled Enable account locking during self-registration. Enable Notification Internally Management Select if you want the notification handling to be managed by the WSO2 Identity Server. If the client application handles notification sending already, unselect it. This check only applies if User Self-Registration is enabled. Enable reCaptcha Enable reCaptcha for self-registration. See Configuring reCaptcha for Challenge Question-Based Password Recovery for more information. User self registration verification link expiry time Set the number of minutes for which the verification link should be valid. The verification code that is provided to the user to initiate the self sign-up flow will be invalid after the time specified here has elapsed.
Alternatively, you can configure the expiry time in the
identity.xml
configuration file.<SelfRegistration> <VerificationCode> <ExpiryTime>1440</ExpiryTime> </VerificationCode> </SelfRegistration>
User self registration SMS OTP expiry time Set the number of minutes for which the SMS OTP should be valid. The minimum time should be one minute. - Ensure that you have set User self registration SMS OTP expiry time and provided a suitable validity time for an SMS OTP.