I have an Angular application with an ASP.NET Core backed.
It uses Auth0 as identity server, which issues access tokens (JWTs) to the angular app.
The back end uses Microsoft.AspNetCore.Authentication.JwtBearer
, and Authorize
attributes on on web API controllers.
Now I want to add some controller actions to server up dynamically generated PDF files. These should only be accessible to authenticated users, and if they have appropriate claims in their access token.
These new endpoints will be accessed via browser link rather than AJAX requests, so I can't send the bearer token in a header (as far as I am aware).
Given the existing auth infrastructure I have in place, what's the easiest way to add security to these new controllers?
The PDFs will be accessed via html anchor elements (e.g. <a href="path/to/doc.pdf" target="_blank">PDF</a>
) which are generated in angular component templates.
I could add the bearer token as a query parameter. The major downside I read about for this approach is that the tokens may be obtainable in server logs etc.
Maybe there is an alternative to download the PDF via AJAX request (in which case the existing use of bearer token in a header would apply), but I'm not sure of a good way to do that.