Page History
No include |
---|
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 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 it is used to differentiate separate username from tenant domain, in multi-tenant environments. For example, user 'Daniel' from the tenant domain WSO2.com has the fully-qualified name [email protected] So, before using the email address as 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. |
Note | ||
---|---|---|
| ||
Configuring the email address as the username in an already running Identity Server is not the production recommended way. Therefore, make sure to change configure it before you begin working with WSO2 IS. |
- Open the <
PRODUCT_HOME>/repository/conf/carbon.xml
file. Look for the commented out configuration
EnableEmailUserName
. Uncomment the configuration to enable email authentication.Code Block language html/xml <EnableEmailUserName>true</EnableEmailUserName>
Open the <
IS_HOME>/repository/conf/claim-config.xml
file and configure theAttributeID
property of thehttp://wso2.org/claims/username
claim ID that is under<Dialect dialectURI="http://wso2.org/claims">
tomail
.Code Block <Claim> <ClaimURI>http://wso2.org/claims/username</ClaimURI> <DisplayName>Username</DisplayName> <AttributeID>mail</AttributeID> <Description>Username</Description> </Claim>
Note This file is checked only when WSO2 IS is starting for the first time. Therefore, if you didnhaven't configure configured this property at the time of starting up the server for the first time, you will get errors at the start up.
Open the
<IS_HOME>/repository/conf/
identity/
file and set the following property toidentity-mgt.properties
true
.Info This step is required due to a known issue that prevents the confirmation codes from being removed after they are used when email usernames are enabled. This occurs because the '@' character (and some special characters) are not allowed in the registry. To overcome this issue, enable hashed usernames when saving the confirmation codes by configuring the properties below.
Code Block language xml UserInfoRecovery.UseHashedUserNames=true
Optionally, you can also configure the following property to determine which hash algorithm to use.
Code Block language xml UserInfoRecovery.UsernameHashAlg=SHA-1
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).
Parameter Description UserNameAttribute
Set the mail attribute of the user. LDAP/Active Directory only
Code Block language html/xml <Property name="UserNameAttribute">mail</Property>
UserNameSearchFilter
Use the mail attribute of the user instead of
cn
oruid
. LDAP/Active Directory onlyCode Block language html/xml <Property name="UserNameSearchFilter">(&(objectClass=identityPerson)(mail=?))</Property>
UserNameListFilter
Use the mail attribute of the user. LDAP/Active Directory only
Code Block language html/xml <Property name="UserNameListFilter">(&(objectClass=identityPerson)(mail=*))</Property>
UserDNPattern
This parameter is used to speed up the LDAP search operations. You can comment out this config. LDAP/Active Directory only
Code Block language html/xml <!--Property name="UserDNPattern">cn={0},ou=Users,dc=wso2,dc=com</Property-->
UsernameJavaScriptRegEx
Change this property that is under the relevant user store manager tag as follows. This property allows you to add special characters like "@" in the username.
Code Block language xml <Property name="UsernameJavaScriptRegEx">^[a-zA-Z0-9._-][email protected][a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$</Property>
UsernameJavaRegEx
This is a regular expression to validate usernames. By default, strings have a length of 5 to 30. Only non-empty characters are allowed. You can provide ranges of alphabets, numbers and also ranges of ASCII values in the RegEx properties.
Code Block language xml <Property name="UsernameJavaRegEx">^[a-zA-Z0-9._-][email protected][a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$</Property>
Realm configurations The
AdminUser
username must use the email attribute of the admin user.Code Block language html/xml <AdminUser> <UserName>[email protected]</UserName> <Password>admin</Password> </AdminUser>
Note Before this configuration, the user having the username admin and password admin was considered the super administrator. The super administrator user cannot be deleted.
After this configuration, the user having the username
[email protected]
is considered the super administrator. The user having the username admin is considered as a normal administrator.Tip If you changed the password of the admin user to something other than 'admin', start the WSO2 IS server using the -Dsetup parameter as shown in the command below.
Code Block sh wso2server.sh -Dsetup
Info With these configuration users can login log in to super tenant with both email user name ([email protected]com) or non-email user names (alice). But for tenant only email user names allowed ([email protected]gmail.com@wso2.com)
Note You can configure email user name without enabling
EnableEmailUserName
property, then users can login to both super tenant and tenant using email and non-email user names. But super tenant users should always use @carbon.super at the end of user names.Restart the server.
...