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:
 

 

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.

 

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

  2. Launch MicroStrategy Web to view the customization.
     

Note: Refer to Applying customization changes to the application for instructions on specific settings that affect whether the customization changes are applied automatically or a restart of the Web server is required.

 

 

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.

 

 

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.   

 

Note: 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.

 

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

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

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

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

  5. Save your changes.
     

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

 

Note: Refer to Applying customization changes to the application for instructions on specific settings that affect whether the customization changes are applied automatically or a restart of the Web server is required.

 

 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.
     

Note: 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.