+1 800 256 3608 (toll-free in North America) or +49 7531 90 60 10| service@combit.com

Authentication with HTML5 Viewer

,

Hello,

our use case for the HTML5 Viewer is the following:

  1. We have an API written in ASP NET MVC Core 3.1
  2. For authentication we’re using JWT, meaning every request that has to be authenticated on the API side has to have an ‘Authorization: Bearer …’ request header
  3. On the frontend we have a single page application written using Angular (v.9)
  4. We want to show a preview of the report

Since the HTML Viewer is only available for ASP.NET Core as a HTML helper for razor pages, we’ve added a server side rendered page that would host our viewer.
In order to authorize the Html5Viewer’s AJAX requests, there is code there that intercepts all XMLHttpRequests and adds an authentication header with the token from local storage.
This approach works, but not entirely - some of the requests are intercepted and some are not (I can’t figure out why is that):

Eg: Here the request with the preview is intercepted, the JWT gets added, and the request succeeds.

The following request with the thumbnail is not intercepted, the JWT is not added, and the request fails with 401 (which is correct - requests without bearer tokens should not be authorized).

First of all, this whole solution feels hacky, since I’m not configuring L&L, but rather adding custom code to add authentication.
Seconds of all, after spending some time with the docs, I haven’t found any reference to how to use the Html5Viewer with JWT tokens.

The question is:
Can you provide us with an example of how to configure the Html5Viewer to use JWT tokens (or point us to the documentation section that describes that, since I haven’t found any)

Regards,
Jürgen Meijerink

We would like to take a closer look at the behavior in a support case. For this reason, if you don’t mind we would like to ask you to open a case via the support center. The solution can then be communicated to everyone in the forum, of course.

Thanks in advance

© combit GmbH