MicroStrategy ONE
Creating a Session from a Custom Login Page
This scenario illustrates how to create a custom External Security Module (ESM) that performs all of the work required to authenticate a user and create or validate a session. It uses a custom log-in page to collect all the information needed to create a session and to determine which MicroStrategy Web page to use as the start page.
This customization is useful when you want the login page to have a distinct "look and feel" that reflects your specific business requirements or environment or when you need greater flexibility—for what information is gathered, what operations take place, how sessions are handled, and how log-in credentials are used for authentication. The logic and the information collected in this sample are simple, but you can add more complex logic and collect more information based on your requirements.
For help in understanding how to perform this customization, the following information is provided for you:
-
Prerequisites for this authentication customization use case
-
Instructions for creating the custom External Security Module with the Web Customization Editor
Prerequisites for this authentication customization use case
The work-flow for this custom authentication scenario assumes that there is no existing session for the user making the request and that you have done the following:
-
Created a custom error page, if desired, to be used if a failure occurs.
-
Created and compiled a custom ExternalSecurity java class that includes code to authenticate and authorize the user using information gathered on the custom login page, and create and manage the session on the Intelligence Server.
-
Created a custom login page that includes code to gather the information needed to authenticate the user and to determine which start page to use.
Instructions for creating the custom External Security Module with the Web Customization Editor
This customization can be accomplished using either of the following methods:
Deploying the plug-in provided with MicroStrategy SDK
MicroStrategy SDK provides a plug-in (ZIP file) that can simply be extracted to the plugins folder to view the customization in MicroStrategy Web. The following steps guide you in locating the plug-in and deploying it.
-
Access the plug-in: JSP version.
-
Extract the plug-in to the plugins subfolder inside the MicroStrategy Web installation folder.
-
Launch MicroStrategy Web to view the customization.
Using the Web Customization Editor to create a plug-in
MicroStrategy SDK provides a Web Customization Editor that can be used to create a customization plug-in that performs your ESM customization. The following steps guide you in creating the plug-in and deploying it.
-
Create a new plug-in and give it a meaningful name, such as CreatingSessionCustomLogin.
-
Exit the Web Customization Editor.
-
Create a custom Java class that extends AbstractExternalSecurity, which implements the ExternalSecurity interface and includes the code to create and manage sessions. Package it in com.microstrategy.sdk.samples.externalsecurity. This custom class must include code to import the necessary MicroStrategy runtime libraries and override the handlesAuthenticationRequest, getCustomLoginURL and getFailureURL methods, as explained below.
-
Override the handlesAuthenticationRequest method so that it returns USE_CUSTOM_LOGIN_PAGE.
-
Override the getCustomLoginURL method so that it returns the URL of a custom login page. This custom login page collects user credentials and other information needed to create a session, redirects to the appropriate start page, and puts the session and other necessary information in the URL.)
- Override the getFailureURL method so that it returns the URL of the page to display if authentication fails.
For this scenario, a sample file—called CustSessionCreation.java is available in the plug-in provided by MicroStrategy SDK. You can use this sample class to see the results of this specific customization and as a model for how to create your own custom class. See Code Explanation for Custom Session Creation Scenario for a detailed explanation of how to write the code required in the custom ESM class.
Compile and save CustSessionCreation.class, with the proper package folder structure, under the plugins/CreatingSessionCustomLogin/WEB-INF/classes folder in the MicroStrategy Web installation directory.
If you used a different plug-in name from the one suggested in this scenario, the path referenced above should reflect your plug-in name.
-
-
Create a custom login page that collects credentials and other information needed for session creation, and determines the appropriate start page to display for users who are successfully logged in.
For this scenario, a sample login page—called CustSessionLoginPage.jsp is available inside the jsp folder of the plug-in provided by the MicroStrategy SDK. You can use this sample page to see the results of this specific customization and as a model for how to create your own custom page. See Code Explanation for Custom Session Creation Scenario for a detailed explanation of how to write the code required in the custom login page.:
Save CustSessionLoginPage.jsp under the plugins/CreatingSessionCustomLogin/jsp folder in the MicroStrategy Web installation directory.
If you used a different plug-in name from the one suggested in this scenario, the path referenced above should reflect your plug-in name.
-
If the Web Customization Editor is closed, launch it again and access your plug-in.
-
Click on MicroStrategy Web Configuration inside the Application Settings view to expand the hierarchical tree. The expanded list comprises the different settings that can be modified to perform customizations.
-
Expand Web Configuration Settings and double-click MicroStrategy Configuration Settings.
-
Click the Application Settings tab at the bottom of the page. For the entry in the External Security Class field under Application Settings, browse to the custom External Security class you saved in step 4 above.
-
Save your changes.
-
Launch MicroStrategy Web to view the customization.
The next time that you open MicroStrategy Web, the application uses your custom External Security class, instead of the default class.:
For specific settings that affect whether customization changes are applied automatically or require a restart of the Web server, see Applying customization changes to the application.
Testing this authentication customization use case
Once you have met the prerequisites and performed the steps listed above, you are ready to test its functioning.
-
Open MicroStrategy Web in a Web browser.
-
Click the link for a project. For example, click the link for MicroStrategy Tutorial. The custom log-in page should be displayed.
-
Log in with valid MicroStrategy user credentials. A session should be successfully created, and you should be able to access the project you selected.
Work-flow for this authentication customization use case
The steps below explain what is happening as the custom ESM attempts to authenticate a user and create a session.
-
A user makes a request for a MicroStrategy Web page from a Web client, and MicroStrategy Web determines that the page requires authentication and that a valid session does not exist for the user.
MicroStrategy Web always checks first to see if there is an existing session. If it is still valid, there is no need to authenticate the user again and processing continues. The following steps are only performed if the user needs to be authenticated— that is, the first time the user logs in or when an existing session has been closed or timed out.
-
MicroStrategy Web creates an instance of the ExternalSecurity class specified in microstrategy.xml, calls the handlesAuthenticationRequest method on this class, and passes in NO_SESSION_FOUND to the method, which returns USE_CUSTOM_LOGIN_PAGE.
-
USE_CUSTOM_LOGIN_PAGE invokes the getCustomLoginURL method.
-
The getCustomLoginURL() method returns the URL of a custom log-in page.
-
If an empty string or NULL is returned, the getFailureURL method is invoked.
-
If the URL returned is bad, HTTP Status Code 404 is returned from the Web server.
-
If the URL returned is good, the application redirects the user to the custom login page, which can be internal or external to MicroStrategy Web.
-
-
The user enters the requested information on the custom login page and submits it.
-
If the user submits the correct credentials information, the custom login page creates a user session on Intelligence Server, and places the session state in the URL using the usrSmgr parameter. Since a valid session state is passed to MicroStrategy Web, the user is given permission to access the Desktop page.