0

I am using Jasper 6.1 and configured my server to allow token based authentication. It works fine when i use token to login from browser. With the valid token, I am able to get into the system without entering username and password.

Now, I am integrating it with visualize.js in order to show reports on our application's web page. Below is request call :-

var authToken = encodeURIComponent("u=jsmith|r=admin|exp=20150831172506-0800|t=ABC");
visualize.config({
server: "http://localhost:8080/jasperserver-pro",
scripts: "optimized-scripts",
logEnabled: true,
logLevel: "error",
auth: {
token: authToken,
preAuth: true,
tokenName: "pp"
}}, function (v) {
   $scope.v = v;
   $scope.reportingInitialized = true;
   $scope.$digest();
}, function (err) {
         alert("Auth error! Server said: " + err.message);
});

However, on successful authentication it is not redirecting to success url but returning the below html with HTTP code 200. Due to which the Authentication is failing with the error message as "Unexpected token <".

Appreciate any help on this.

<head>
<title></title>
<meta http-equiv="refresh" content="0;url=home.html">
<script language="javascript" type="text/javascript">
window.location="home.html";
</script>
</head>
<body>
If your browser doesn't automatically go there,
you may want to go to <a href="home.html">the destination</a>
manually.
</body>
</html>
Dharmveer Jain
  • 121
  • 2
  • 11
  • 1
    On debugging this issue, found that the above issue is happening when there is already an active session. The below code addresses this issue (though not the best way to solve it) `$(window).bind('beforeunload', function() { visualize(function(v) { v.logout(); }); });` – Dharmveer Jain Sep 09 '15 at 12:20
  • After the above fix, after authentication the request [http:///jasperserver-pro/?pp=] is getting redirected to [http:///jasperserver-pronull]. Not sure from where it is getting null in the url. Appreciate any help on this. – Dharmveer Jain Sep 09 '15 at 12:25

4 Answers4

1

Here is the resolution for this issue for other's benefit:

The jsonRedirectUrl was missing in the applicationContext-externalAuth-preAuth.xml

<property name="jsonRedirectUrl" ref="authSuccessJsonRedirectUrl"/>

Also following lines need to be removed from this file to have the report show up without any error:

 <!-- marker disabling JIAuthenticationSynchronizer: pre-5.1 external auth config-->
    <alias name="${bean.authenticationProcessingFilter}" alias="proxyAuthenticationProcessingFilter"/>

Above solution is tested and working on Jasper Server 6.1

Dharmveer Jain
  • 121
  • 2
  • 11
0

I have installed JRS 6.1 and :

  • The was already in the applicationContext-externalAuth-preAuth.xml

  • And I have commented the "alias..." line

But still, when I do refresh my report page, the report is not displayed. I have to delete my cookies so that the report appears.

Did it really work for you ?

  • If you are already authenticated, then use the same token. If for every report access, you try to authenticate then report will fail to load. – Dharmveer Jain Oct 04 '15 at 03:04
  • @jade-jaber Actually this is the expected behavior with visualize.js. As DharmveerJain said. You should not send second authentication call with same token – M. Atif Riaz Nov 04 '15 at 17:07
0

We found that the problem was that the first request establishes a session. If you send a new token with the second request while the first session is still active then the request fails. You need to modify your application to either continue to use the same token for the browser session or you could logout the user before sending the second request.

0

This is the expected behavior with visualize.js authentication so here are 2 options which I have through of using in my application

Approach 1

Reuse authentication call as per visualize.js documentation

use visualize.configure

visualize.config({
  auth: {
    token: "token",
    organization: "organization_1"
  }
});

then use visualize function to serve report 1 and report 2

// report 1
visualize(function(v) {
  v("#container1").report({
    resource: "/public/Samples/Reports/06g.ProfitDetailReport",
    error: function(err) {
      alert(err.message);
    }
  });
});

// report 2
visualize(function(v) {
  v("#container2").report({
    resource: "/public/Samples/Reports/State_Performance",
    error: function(err) {
      alert(err.message);
    }
  });
});

Approach 2

This approach which is not desirable. every time you want to show a report do following

  • send login call
  • serve the report
  • send a logout call
M. Atif Riaz
  • 492
  • 1
  • 9
  • 22