Reputation: 119
I have an ASP.NET Core 3.1 API which already uses OAuth for authorization. I added healthchecks middleware and I would like to make it protected with basic auth so that client which check the health status can simply provide credentials to check the service health. So far I did not manage to configure it for the healthcheck endpoint. Any clue how this can be added?
Upvotes: 2
Views: 1989
Reputation: 382
You can use RequireAuthorization method. For example:
app.UseEndpoints(endpoints =>
{
endpoints.MapHealthChecks("/health").RequireAuthorization();
});
Upvotes: -1