MicroStrategy ONE

Restricting Access during Certain Times

This scenario illustrates how to create a custom External Security Module (ESM) that restricts user access based on custom authorization criteria. The specific example used in this customization prevents non-administrative users from accessing the application on weekends, while allowing administrators to use the application any time. The code explanation for this example and the steps in this scenario can be used as a basis for applying any type of additional authorization criteria you choose. in each case, you simply include additional authorization criteria to the isRequestAuthorized method, which is called with every request.

For help in understanding how to perform this customization, the following information is provided for you:

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 add additional authorization criteria— in this example, based on user group and system time.

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. 

  1. Access the plug-in: JSP version

  2. Extract the plug-in to the plugins subfolder inside the MicroStrategy Web installation folder.  

  3. 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.

  1. Launch the Web Customization Editor

  2. Create a new plug-in and give it a meaningful name, such as RestrictingAccess

  3. Exit the Web Customization Editor. 

  4. Create a custom Java class that extends AbstractExternalSecurity, which implements the ExternalSecurity interface. Package it in com.microstrategy.sdk.samples.externalsecurity. This custom class must include code to import the necessary MicroStrategy runtime libraries and override the isRequestAuthorized method, as explained below.:

    • Override the isRequest:Authorized method so that it obtains the system time, determines whether the user is an administrator, and restricts access to the application during certain times if the user is not an administrator.:

    For this scenario, a sample java file— called RestrictUserAccess.java is available in the plug-in provided by MicroStrategy SDK. You can use this sample class to see the results of this type of customization and as a model for how to create your own custom class. See Code Explanation for Restricting Access Scenario for a detailed explanation of how to write the code required in the custom ESM class.:

    Compile and save RestrictUserAccess.class in the appropriate package structure under the plugins/RestrictingAccess/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.

  5. If the Web Customization Editor is closed, launch it again and access your plug-in

  6. 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. 

  7. Expand Web Configuration Settings and double-click MicroStrategy Configuration Settings

  8. 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. 

  9. Save your changes. 

  10. 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 this customization.

  1. Check the system date and time to make sure that it is a weekday.

  2. Open MicroStrategy Web in a Web browser and click the link for MicroStrategy Tutorial. The default log-in page should be displayed.

  3. Log in with valid MicroStrategy credentials for either an administrator or a non-administrative user, and you should be granted access to the application. 

  4. Now, change the system date and time to a weekend day. 

  5. Log in as an administrator, and you should be granted access to the application.

  6. Log out and log back in with valid MicroStrategy credentials for a non-administrative user, and you should be denied access.

Be sure to change the system date and time back to the proper settings.

Work-flow for this authentication customization use case

The steps below explain what is happening as the custom ESM attempts to determine whether the user is authorized to have access to the application.

  1. 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 (that is, there is no session ID). 

  1. MicroStrategy Web creates an instance of the custom 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_MSTR_DEFAULT_LOGIN. 

  2. USE_MSTR_DEFAULT_LOGIN redirects processing to the default MicroStrategy Web log-in page. 

  3. The user enters the requested information on the default log-in page and submits it. 

  4. The information is passed to MicroStrategy Web, and it  invokes the processMSTRLoginForm method, which authenticates the user. 

  5. MicroStrategy Web calls the isRequestAuthorized method on the custom ESM, which has been customized to restrict access to certain users based on certain criteria— in this example, restricting access for non-administrative users during weekends. 

    • If an error occurs during this process, the getFailureURL method is invoked and no session is created on Intelligence Server. 

    • If no error occurs during this process, the additional authorization criteria are applied and access is granted or denied based on data and time and user group.