How to use authentication for subreports

1 Answer 201 Views
Report Designer - Web Report Viewer - HTML5
Hannes
Top achievements
Rank 1
Hannes asked on 11 Jan 2022, 10:12 AM
Hello,

I'm using WebReportDesigner in the React application. One of our key requirements is to use Authentication, because the users from different tenants have different storages, different settings, configuration, etc.
Since the WebReportDesigner does not support Authentication, I've used the approach described here: https://feedback.telerik.com/reporting/1486109-pass-bearer-token-authentication-with-web-report-designer-api-requests 

Everything works fine until we use the URI subreport in our report. It fails to render with the error message:
"An error has occurred while processing SubReport 'subReport1':Response status code does not indicate success: 401 (Unauthorized)."

The Report Engine most likely makes internal HTTP call to the "/reports/{reportId}" without authorization HTTP headers, cookies, etc., and that's why the HTTP call could not be authenticated.

I have also tried to override the virtual "IActionResult GetReport(string reportId)" method, but can't find any useful info about the logged-in user.

Btw: we face the very same issue in the WebViewer, which supports authentication (by passing authenticationToken - it's not forwarded when resolving the subreports).

How can we use subreports with our authorized API controllers?

Thank you!

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 13 Jan 2022, 03:44 PM

Hi Hannes,

I have already replied to the same questions in the support ticket you raised on the same topic. For the benefit of our community, I will summarize my reply also in this public thread.

Based on the description of the problem and the received error, I suspect that you have referenced the SubReport ReportSource as a URI resource that is not a file on the file system. Please, note that the UriReportSource should reference TRDX and TRDP files from the file system. It cannot work with other resources.

If the above assumption is correct, our code would try to resolve the URI and will expect a valid server-side ReportSource to be found there. I suspect that the problem occurs when trying to access the URI as there is no authentication header. We just make a get request to the URI as if you paste the link in the browser. However, even if the request was successful, the UriReportSource wouldn't be valid and the Reporting engine wouldn't be able to resolve the subreport. The same is valid also for the REST Service as it uses the same server-side ReportSources. Hence, this would explain why the same problem occurs also when rendering the report with such SubReport in the viewer.

As a workaround, I suggest setting the SubReport ReportSource with an Expression to a Custom User Function. The user function should return an InstanceReportSource, which ReportDocument is the report instance. You may instantiate a TRDP report with our ReportPackager and the TRDX report with the ReportXmlSerializer. In the user function, you may make a custom request for the report content that includes authentication.

Regards,
Todor
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Tags
Report Designer - Web Report Viewer - HTML5
Asked by
Hannes
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or