![]() |
VOOZH | about |
dotnet add package PanoramicData.HealthChecks.BasicAuthentication --version 10.0.17
NuGet\Install-Package PanoramicData.HealthChecks.BasicAuthentication -Version 10.0.17
<PackageReference Include="PanoramicData.HealthChecks.BasicAuthentication" Version="10.0.17" />
<PackageVersion Include="PanoramicData.HealthChecks.BasicAuthentication" Version="10.0.17" />Directory.Packages.props
<PackageReference Include="PanoramicData.HealthChecks.BasicAuthentication" />Project file
paket add PanoramicData.HealthChecks.BasicAuthentication --version 10.0.17
#r "nuget: PanoramicData.HealthChecks.BasicAuthentication, 10.0.17"
#:package PanoramicData.HealthChecks.BasicAuthentication@10.0.17
#addin nuget:?package=PanoramicData.HealthChecks.BasicAuthentication&version=10.0.17Install as a Cake Addin
#tool nuget:?package=PanoramicData.HealthChecks.BasicAuthentication&version=10.0.17Install as a Cake Tool
Heath checks that support checking the versions of items in the deployed application.
All of the code to enable use of health checks goes in Program.cs (or Startup.cs on older systems).
Add the PanoramicData.HealthChecks.Versions nuget package to the host application.
Add the required health checks using the extension methods to the WebApplicationBuilder class:
builder.Services.AddVersionHealthCheck();
builder.Services.AddAssembliesHealthCheck();
Add only those healthchecks in whose results you are interested. Adding more than you need exposes potentially sensitive information unnecessarily, as well as bloating the JSON response sent for every request.
Define an authorization scheme using a policy name to which we can refer later. Any form of authentication can be used as you prefer; we use Basic Authentication for this demo so that the demo is standalone.
const string HEALTHCHECKS_AUTHPOLICY = "HeathChecksPolicy";
builder.Services
.AddHealthChecksBasicAuthentication(builder.Configuration, HEALTHCHECKS_AUTHPOLICY);
The AddHealthChecksBasicAuthentication extension method is part of the optional package PanoramicData.HealthChecks.BasicAuthentication. If you want to make use of this authentication method then you must additionally add this Nuget package to your solution, and supply security credentials in the secrets for the application. The structure of the secrets can be seen in userSecrets.example.json in the Demo project for using either a HashedPassword or Password.
Warning As always, remember to use a secure connection when using Basic Authentication so that sensitive information is not exposed in transit.
Next, we must ensure that authentication and authorization are enabled, so add them to the pipeline if they are not already part of it:
app.UseAuthentication();
app.UseAuthorization();
Finally, define the healthcheck endpoint, specifying its URL and the authorization policy to be applied:
app.MapHealthChecks("_secureHealth", new()
{
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
})
.RequireAuthorization(HEALTHCHECKS_AUTHPOLICY);
You can specify any authorization policy as part of the call to
RequireAuthorization - there is no limitation to the type of the policy
or the authentication scheme with which that policy is asssociated.
Note that we must specify a custom response writer in the MapHealthChecks
method to enable output of custom data from the health checks. If no custom
writer is defined then only the enum denoting the overall status of each
healthcheck will be returned to the caller. It is this custom response writer
that adds the custom data exposed by the health check to the caller.
Warning Enabling writing of custom data to the response risks exposing sensitive data captured by other health checks that are not in your control. Be sure to check the contents of responses each time you add a new healthcheck, to minimise the risk that sensitive information is exposed to callers to whom it is not appropriate.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on PanoramicData.HealthChecks.BasicAuthentication:
| Package | Downloads |
|---|---|
|
PanoramicData.HealthChecks.BasicAuthentication.HashGenerator
Console application for generating ASP.NET Core Identity password hashes for PanoramicData.HealthChecks.BasicAuthentication. |
This package is not used by any popular GitHub repositories.
Initial release