At present most people prefer to use their email as their username for any login since it's easy to remember the email rather than several non-email usernames. From this post my aim is to cover up how to enable email as username or email authentication for WSO2 products.
To enable Email as username/ Email authentication the following steps should be followed :
1. Enable Email Authentication in carbon.xml
You have to go to [Product_Home]/repository/conf/carbon.xml and enable the email authentication as follows :
<EnableEmailUserName>true</EnableEmailUserName>
2.Provide the Correct Regular expression to allow Email addresses for user store via the user-mgt.xml
You can find the user-mgt.xml in [Product_Home]/repository/conf directory
<Property name="UsernameJavaRegEx">[a-zA-Z0-9@._-|//]{3,30}$</Property>
3. Create the Admin user with an Email address in user-mgt.xml
<AdminUser>
<UserName>admin@wso2.com</UserName>
<Password>admin</Password>
</AdminUser>
Now you can login as admin@wso2.com and create users using Email as username
The above few steps will enable Email authentication. If you want to allow both email as username and normal authentication you just have to add the following line to your user store configuration. (jdbc user store/ldap/Active directory)
<Property name="UsernameWithEmailJavaScriptRegEx">[a-zA-Z0-9@._-|//]{3,30}$</Property>
That's it!!
thanks was very useful. but needed to add UsernameWithEmailJavaScriptRegEx property as well just to create a new user with email user-name. without that I keep getting errors when creating users using console.
ReplyDeleteThank you for sharing. See also http://xacmlinfo.org/2014/10/07/email-username-with-identity-server/
ReplyDelete