asp.net core 3 allows to set FallbackPolicy to make the endpoints secure by default:
services.AddAuthorization(options =>
{
options.FallbackPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
});
It is a great feature, but I have a HealthCheck endpoint too, that requires Authorization now.
services.AddHealthChecks();
[...]
app.UseEndpoints(endpoints => {
endpoints.MapHealthChecks("/health");
endpoints.MapControllers();
});
How do I allow anonymous access to the HealthCheck endpoint (NO authentication or authorization)?