Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access js and css resources when UI requires authorization. #2082

Open
MelGrubb opened this issue Oct 24, 2023 · 0 comments
Open

Can't access js and css resources when UI requires authorization. #2082

MelGrubb opened this issue Oct 24, 2023 · 0 comments
Labels

Comments

@MelGrubb
Copy link

What happened:
I am implementing a very simple querystring-based auth, similar to how Azure functions can require keys to be passed in the URL.
The code looks like this:

.RequireAuthorization(builder => builder.RequireAssertion(handlerContext => codes.Contains((handlerContext.Resource as HttpContext)?.Request.Query["auth"].ToString())));

This works fine for the health data endpoint. It refuses to return anything unless you pass it an "auth" value that appears in the list of authorized codes. I even have the UI showing the data using one of those codes. Don't get hung up on the name. It could be "code" or "key" or anything, really. So far, so good.

When I try to apply that same .RequireAuthorization to MapHealthChecksUI, I run into a problem. The UI will not display unless you pass the same kind of auth value. If you pass it a code, the UI loads, but it's blank, and the console is complaining that it can't get to any of the js or css files, so you're left with a blank page. Is there anything I can configure so that the UI will use the same code it was given in requests for those resources?

What you expected to happen:
I expected the UI to show completely.

How to reproduce it (as minimally and precisely as possible):

  1. Apply the snippet above to the MapHealthChecksUI call.
  2. Populate "codes" with some sample values like this:
var codes = new[] { "foo", "bar" };
  1. Call the UI endpoint, passing one of the allowed codes.

Source code sample:

Anything else we need to know?:

Environment:

  • .NET Core version 6
  • Healthchecks version 7.0.2
  • Operative system: Windows
  • Others:
@sungam3r sungam3r added the UI label Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants