Table of Contents

BasicAuthenticationMiddleware Class

Definition

Provides a HTTP Basic Authentication middleware implementation for ASP.NET Core.

public class BasicAuthenticationMiddleware : ConfigurableMiddleware<BasicAuthenticationOptions>, IConfigurable<BasicAuthenticationOptions>
Inheritance
BasicAuthenticationMiddleware
Implements
Inherited Members

Examples

The following example demonstrates how to construct BasicAuthenticationMiddleware with inline option setup.

using System;
using System.Threading.Tasks;
using Cuemon.AspNetCore.Authentication.Basic;

namespace MyApp.Examples;

public static class BasicAuthenticationMiddlewareExample
{
    public static void Demonstrate()
    {
        var middleware = new BasicAuthenticationMiddleware(_ => Task.CompletedTask, options =>
        {
            options.Realm = "docs-example";
            options.RequireSecureConnection = false;
            options.Authenticator = (username, password) => null;
        });

        Console.WriteLine(middleware.Options.Realm);
    }
}

Constructors

Name Description
BasicAuthenticationMiddleware(RequestDelegate, IOptions<BasicAuthenticationOptions>)

Initializes a new instance of the BasicAuthenticationMiddleware class.

BasicAuthenticationMiddleware(RequestDelegate, Action<BasicAuthenticationOptions>)

Initializes a new instance of the BasicAuthenticationMiddleware class.

Methods

Name Description
InvokeAsync(HttpContext)

Executes the BasicAuthenticationMiddleware.