Using Email Address as the Username

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/.

Using Email Address as the Username

WSO2 products can be configured to authenticate users using their attributes. For example, these attributes can be email or mobile number instead of the username. If your organization decide to use users email as their username, this topic provides instructions on how to set up your WSO2 product to authenticate users using their email.

'@' is a special character in WSO2 products, since its used to differentiate username from tenant domain, in multi-tenant environments. 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 tenant domain separator. Do the following to configure this.

Configuring email as user in already running Identity Server is not the production recommended way.

  1. Open the <PRODUCT_HOME>/repository/conf/carbon.xml file.

  2. Look for the commented out configuration EnableEmailUserName. Uncomment the configuration to enable email authentication.

    <EnableEmailUserName>true</EnableEmailUserName>
  3. Open the <IS_HOME>/repository/conf/identity/identity-mgt.properties file and set the following property to true

    UserInfoRecovery.UseHashedUserNames=true

    Optionally, you can also configure the following property to determine which hash algorithm to use.

    UserInfoRecovery.UsernameHashAlg=SHA-1
  4. Open the <PRODUCT_HOME>/repository/conf/user-mgt.xml file and add the following property under the relevant user store manager tag, such as ReadWriteLDAPUserStoreManager, ActiveDirectoryUserStoreManager or any other user store manager tag.
    This property determines the username validation that will be enforced when the EnableEmailUserName option is enabled. 

    <Property name="UsernameWithEmailJavaScriptRegEx">^[\S]{3,30}$</Property>
  5. Configure the following set of parameters in the user store configuration, depending on the type of user store you are connected to (LDAP/Active Directory/JDBC).

  6. Restart the server.

Related Topics

For more information on how to configure primary and secondary user stores, see Configuring User Stores.