DigestAuthenticationMiddleware Class
Definition
- Namespace
- Cuemon.AspNetCore.Authentication.Digest
- Assemblies
- Cuemon.AspNetCore.Authentication.dll
Provides a HTTP Digest Access Authentication middleware implementation for ASP.NET Core.
public class DigestAuthenticationMiddleware : ConfigurableMiddleware<INonceTracker, DigestAuthenticationOptions>, IConfigurable<DigestAuthenticationOptions>
- Inheritance
-
DigestAuthenticationMiddleware
- Implements
- Inherited Members
Examples
The following example demonstrates how to construct DigestAuthenticationMiddleware with inline option setup.
using System;
using System.Security.Claims;
using System.Threading.Tasks;
using Cuemon.AspNetCore.Authentication.Digest;
namespace MyApp.Examples;
public static class DigestAuthenticationMiddlewareExample
{
public static void Demonstrate()
{
var middleware = new DigestAuthenticationMiddleware(_ => Task.CompletedTask, options =>
{
options.Realm = "docs-example";
options.RequireSecureConnection = false;
options.Authenticator = (string username, out string password) =>
{
password = username == "Agent" ? "Test" : null;
return password == null ? null : new ClaimsPrincipal(new ClaimsIdentity());
};
});
Console.WriteLine(middleware.Options.Realm);
}
}
Constructors
| Name | Description |
|---|---|
| DigestAuthenticationMiddleware(RequestDelegate, IOptions<DigestAuthenticationOptions>) | Initializes a new instance of the DigestAuthenticationMiddleware class. |
| DigestAuthenticationMiddleware(RequestDelegate, Action<DigestAuthenticationOptions>) | Initializes a new instance of the DigestAuthenticationMiddleware class. |
Methods
| Name | Description |
|---|---|
| InvokeAsync(HttpContext, INonceTracker) | Executes the DigestAuthenticationMiddleware. |