CORS-Cross Origin Resource Sharing in Jaspersoft

Posted on by By admin, in Jaspersoft | 0

Introduction:

CORS is a mechanism that allows restricted resource on a web page to be requested from another domain outside the domain from which the first resource was served.

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Get your 30 Days Trail Version

Enable CORS in jasper:

  1. Add the CORS properties in web.xml file in Jasper Server
  2. 	...\apache-tomcat\webapps\jasperserver-pro\WEB-INF
    

    Reference Link: http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#CORS_Filter

  3. Add Remote Domain Header in cors.allowed.headers in cors filter properties
  4. Add withCredentials property and Remote Domain property in Ajax call
	
To pass credentials to cross-domain
		Reference: http://api.jquery.com/jquery.ajax/
				xhrFields: {
					withCredentials: true
				}
				
	To allow CSRF protection
Reference:https://community.jaspersoft.com/documentation/tibco-jasperreports-server-security-guide/v630/configuring-csrf-protection
				headers: {
					"X-Remote-Domain": "1"
				}

CORS Properties:

<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>
  <init-param>
    <param-name>cors.allowed.methods</param-name>
    <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
  </init-param>
  <init-param>
    <param-name>cors.allowed.headers</param-name>

    <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,X-Remote-Domain</param-value>
  </init-param>
  <init-param>
    <param-name>cors.exposed.headers</param-name>
    <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
  </init-param>
  <init-param>
    <param-name>cors.support.credentials</param-name>
    <param-value>true</param-value>
  </init-param>
  <init-param>
    <param-name>cors.preflight.maxage</param-name>
    <param-value>10</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.

Click Here to Free Download

In case if you have any queries please get us at support@helicaltech.com

Thank You
Rupam Bhardwaj
Helical IT Solutions Pvt Ltd

logo

Best Open Source Business Intelligence Software Helical Insight Here

logo

A Business Intelligence Framework


logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments