Skip to content

Instantly share code, notes, and snippets.

@yanli0303
Last active July 16, 2021 19:49
Show Gist options
  • Save yanli0303/fa9e1cbc0a12bee7e11701c4d39d7ca7 to your computer and use it in GitHub Desktop.
Save yanli0303/fa9e1cbc0a12bee7e11701c4d39d7ca7 to your computer and use it in GitHub Desktop.

Tomcat CORS

https://www2.microstrategy.com/producthelp/Current/Office/en-us/Content/enable_cors_settings.htm

In conf/web.xml

<filter>
   <filter-name>CorsFilter</filter-name>
   <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
   <init-param>
     <param-name>cors.allowed.origins</param-name>
     <param-value>*</param-value>
   </init-param>
 </filter>
 <filter-mapping>
   <filter-name>CorsFilter</filter-name>
   <url-pattern>/*</url-pattern>
 </filter-mapping>

Apache CORS

Tomcat HTTPS

<Connector
            protocol="org.apache.coyote.http11.Http11NioProtocol"
            port="8443"
            maxThreads="200"
            scheme="https"
            secure="true"
            SSLEnabled="true"
            keystoreFile="C:/server.pfx"
            keystoreType="PKCS12"
            keystorePass="test"
            clientAuth="false"
            sslProtocol="TLS" />

SameSite

  1. If context.xml doesn't already exist in the following folder location, create it:
  C:\Program Files (x86)\Common Files\Tomcat\apache-tomcat-9.0.30\webapps\MicroStrategyLibrary\META-INF\context.xml
  1. Add the following to context.xml:
<Context>
  <CookieProcessor sameSiteCookies="none"/>
</Context>
  1. Uncomment or copy the cookieProcessorFilter declaration highlighted below in C:\Program Files (x86)\Common Files\Tomcat\apache-tomcat-9.0.30\webapps\MicroStrategyLibrary\WEB-INF\web.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">;
  <display-name>MicroStrategy Library</display-name>
  <filter>
    <filter-name>cookieProcessorFilter</filter-name>
    <filter-class>com.microstrategy.web.filter.CookieProcessorFilter</filter-class>
    <init-param>
    <param-name>sameSite</param-name>
    <param-value>NONE</param-value>
    </init-param>  
  </filter>
  <filter-mapping>
  <filter-name>cookieProcessorFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
</web-app>
  1. Note the sameSite param-value above is NONE to permit embedding. Other valid values include UNSET, LAX, or STRICT.
  2. Ensure your Tomcat is configured to support HTTPS.
  3. Restart Tomcat.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment