Table of Contents

DigestAuthenticationOptions Class

Definition

Configuration options for DigestAuthenticationMiddleware. This class cannot be inherited.

public sealed class DigestAuthenticationOptions : AuthenticationOptions, IValidatableParameterObject, IParameterObject
Inheritance
DigestAuthenticationOptions
Implements
Inherited Members

Examples

The following example demonstrates how to configure DigestAuthenticationOptions with a realm, digest algorithm, and authenticator delegate.

using System;
using System.Security.Claims;
using Cuemon.AspNetCore.Authentication.Digest;

namespace MyApp.Examples;

public static class DigestAuthenticationOptionsExample
{
    public static void Demonstrate()
    {
        var options = new DigestAuthenticationOptions
        {
            DigestAlgorithm = DigestCryptoAlgorithm.Sha256,
            Realm = "docs-example",
            RequireSecureConnection = false,
            Authenticator = (string username, out string password) =>
            {
                password = username == "Agent" ? "Test" : null;
                return password == null
                    ? null
                    : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme));
            }
        };

        options.ValidateOptions();

        Console.WriteLine(options.DigestAlgorithm);
    }
}

Constructors

Name Description
DigestAuthenticationOptions()

Initializes a new instance of the DigestAuthenticationOptions class.

Properties

Name Description
Authenticator

Gets or sets the function delegate that will perform the authentication from the specified username.

DigestAlgorithm

Specifies the cryptographic algorithm used in HTTP Digest Access Authentication. Default is Sha256.

NonceExpiredParser

Gets or sets the function delegate for parsing nonce string values for expiration.

NonceGenerator

Gets or sets the function delegate for generating nonce string values.

NonceSecret

Gets or sets the function delegate for retrieving the cryptographic secret used in nonce string values.

OpaqueGenerator

Gets or sets the function delegate for generating opaque string values.

Realm

Gets the realm that defines the protection space.

UseServerSideHa1Storage

Gets or sets a value indicating whether the server should bypass the calculation of HA1 password representation.

Methods

Name Description
ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

See Also