Skip to end of metadata
Go to start of metadata

WSO2 products can be configured to authenticate users using their attributes such as email or mobile number instead of the username. This topic provides instructions on how to set up your WSO2 product to authenticate users by using their email.

The '@' is a special character in usernames of WSO2 products as it is used in multi-tenant environments to build the user's fully-qualified name. For example, user daniel from the tenant domain WSO2.com has the fully-qualified name daniel@WSO2.com. So before using the email username we need to configure the WSO2 products to differentiate between the '@' symbol in the user's emails and usernames. For this, we need to configure the  carbon.xml file.

  1. Open the carbon.xml file, which is in the <ES_HOME>/repository/conf directory.
  2. Look for the commented out configuration EnableEmailUserName. Uncomment the configuration to enable email authentication.

  3. Open the user-mgt.xml file found in the <ES_HOME>/repository/conf directory and configure the following. 

    The user-mgt.xml file consists of configurations for the primary user store. If you are trying to configure this for a secondary user store, modify the relevant user store configuration file found in the <ES_HOME>/repository/deployment/server/userstores directory instead.

  4. Configure the following set of parameters in the user-mgt.xml file under the relevant user store manager tag, depending on the type of user store you are connected to (LDAP/Active Directory/ JDBC).

    Note: These properties have not been added by default for the JDBCUserStoreManager. Therefore, if you are using a JDBC-based user store, you need to add the properties marked with an asterisk * to the user-mgt.xml file under the relevant user store manager tag. For any other type of user store, simply modify the values of all the properties listed below.



    * (This property is relevant to JDBCUserStoreManager)

    For this, you need to set mail attribute of the user.

    <Property name="UserNameAttribute">mail</Property>

    For this, you need to use the mail attribute of the user instead of cn or uid.

    <Property name="UserNameSearchFilter">(&amp;(objectClass=identityPerson)(mail=?))</Property>

    For this, you need to use the mail attribute of the user.

    <Property name="UserNameListFilter">(&amp;(objectClass=identityPerson)(mail=*))</Property>

    This parameter is used to speed-up the LDAP search operations. You can comment out this config.

    <!--Property name="UserDNPattern">cn={0},ou=Users,dc=wso2,dc=com</Property-->


    * (This property is relevant to JDBCUserStoreManager)

    Add the following property under the relevant user store manager tag. This property enables you to add special characters like "@" in the username.

    <Property name="UsernameWithEmailJavaScriptRegEx">[a-zA-Z0-9@._-|//]{3,30}$</Property>
    Realm configurations

    The AdminUser username should use the email attribute of the admin user.

  5. Open the identity.xml file, which is in the <ES_HOME>/repository/conf/identity directory.
  6. Add the following event listener after the </SessionContextCache> element in the identity.xml file.
    This registers a set of listeners in the identity.xml of the WSO2 ES product that allows it to work an LDAP. These listeners prevent the default listeners from being registered as they do not work with Read Only LDAPs.

       <EventListener type="org.wso2.carbon.user.core.listener.UserOperationEventListener" name="org.wso2.carbon.user.mgt.workflow.userstore.UserStoreActionListener" orderId="10" enable="true" />
       <EventListener type="org.wso2.carbon.user.core.listener.UserOperationEventListener" name="org.wso2.carbon.identity.mgt.IdentityMgtEventListener" orderId="50" enable="false" />
       <EventListener type="org.wso2.carbon.user.core.listener.UserOperationEventListener" name="org.wso2.carbon.identity.scim.common.listener.SCIMUserOperationListener" orderId="90" enable="true" />
       <EventListener type="org.wso2.carbon.identity.core.handler.AbstractIdentityMessageHandler" name="org.wso2.carbon.identity.data.publisher.application.authentication.impl.DASLoginDataPublisherImpl" orderId="10" enable="false" />
       <EventListener type="org.wso2.carbon.identity.core.handler.AbstractIdentityMessageHandler" name="org.wso2.carbon.identity.data.publisher.application.authentication.impl.DASSessionDataPublisherImpl" orderId="11" enable="false" />
       <EventListener type="org.wso2.carbon.identity.core.handler.AbstractIdentityMessageHandler" name="org.wso2.carbon.identity.data.publisher.application.authentication.AuthnDataPublisherProxy" orderId="11" enable="false" />
  • No labels