Tuesday, September 1, 2015

Customize login page of WSO2 Identity Server based on different tenants

Following post https://docs.wso2.com/display/IS500/Customizing+Login+Pages, explains how to customize the login page of Identity Server based on different Service Providers. In this post I will explain how you can customize SAML2 SSO login page based on different tenants.

As explained in above post, you could go ahead with either two methods, and here I will be talking bout the method where to use a JSP to direct to relevant custom login page.  The default login page is located at <IS_HOME>/repository/deployment/server/webapps/authenticationendpoint/login.jsp.

1.Rename login.jsp to default_login.jsp.
2. Create a new file with file name as login.jsp, and add below content. 
Note: Make sure you don't add any additional spaces as this would lead to errors later. Therefore you can open this file in an IDE and check for any errors.

<% 
String tenant = request.getParameter("tenantDomain");

if (tenant.equals("abc.com")) {
 RequestDispatcher dispatcher = request.getRequestDispatcher("abc_login.jsp");
 dispatcher.forward(request, response);
} else {
 RequestDispatcher dispatcher = request.getRequestDispatcher("default_login.jsp");
 dispatcher.forward(request, response);
}
  %> 
 


Above is a sample code , so you could add different if cases, based on your tenants. Now what you need to do is, make sure your SP sends  request parameter named 'tenantDomain' , so this code snippet can pick up that value.  

No comments:

Post a Comment