Self Registering to a Secondary Userstore in WSO2 Identity Server

Shan Chathusanda Jayathilaka
4 min readAug 26, 2022

Hi all, hope you all in good shape. Today we will discuss a customization that can be done using WSO2 Identity Server.

Guys, WSO2 Identity Server 6.0.0 is now released with cool new features. You can get the product from the official website or from the GitHub.

In WSO2 Identity Server we can enable the user self registration feature. When the users are self registering, the user accounts will be created under the PRIMARY userstore domain. This behavior can be changed. The users can be registered under a different userstore. We can follow two options for this.

Let’s say we already have a secondary userstore configured in WSO2 Identity Server named as CUSTOMER.

Option 01

We can instruct the self registering users to add the username with the userstore domain.

Ex : CUSTOMER/Alex

Option 02

We can add the userstore domain from the self registration page by doing a simple customization. Then the users can add only the username to the username input and proceed.

Let’s do the customization.

Here I already configured a JDBC secondary userstore in WSO2 Identity Server. You can refer Configure Secondary Userstore documentation for more information. Also I have added the Email Configurations and enabled the Self Registration as well.

Secondary Userstore Configurations

Now you can change the self registration JSP page with the userstore domain name. Go to <IS-HOME>/repository/deployment/server/webapps/accountrecoveryendpoint and open self-registration-with-verification.jsp and self-registration-username-request.jsp files in a text editor.

Now add the follwing change to self-registration-with-verification.jsp file.

Now add the follwing change to self-registration-username-request.jsp file.

The JSP change contains a banner that can inform the user about the userstore that the user will be registering. After doing the change, restart the Identity Server to deploy the changes.

Now go to myaccount by using https://<HOST>:<PORT>/myaccount. Click on Create Account. You will be redirected to the following page.

Self Registration Page

Add the username and click on Proceed to Self Register. If the entered username is available then you will be redirected to the Create New Account page where you can enter the details to create the user account. After completing that click on Register.

Then you will receive a mail for the account confirmation. After you confirm the account you can use the created user account for the login purposes.

That’s all guys. Simple and clean. That’s the end of this blog. Let’s meet with another blog.

Stay Safe….!!!!! :-)

References

https://www.flaticon.com/

--

--

Shan Chathusanda Jayathilaka

Senior Software Engineer @ WSO2 | Graduate in Computer Science, University of Ruhuna