Table of Contents

Class BasicAuthenticationMiddleware

Namespace
Cuemon.AspNetCore.Authentication.Basic
Assembly
Cuemon.AspNetCore.Authentication.dll

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

BasicAuthenticationMiddleware(RequestDelegate, IOptions<BasicAuthenticationOptions>)

Initializes a new instance of the BasicAuthenticationMiddleware class.

public BasicAuthenticationMiddleware(RequestDelegate next, IOptions<BasicAuthenticationOptions> setup)

Parameters

next RequestDelegate

The delegate of the request pipeline to invoke.

setup IOptions<BasicAuthenticationOptions>

The BasicAuthenticationOptions which need to be configured.

BasicAuthenticationMiddleware(RequestDelegate, Action<BasicAuthenticationOptions>)

Initializes a new instance of the BasicAuthenticationMiddleware class.

public BasicAuthenticationMiddleware(RequestDelegate next, Action<BasicAuthenticationOptions> setup)

Parameters

next RequestDelegate

The delegate of the request pipeline to invoke.

setup Action<BasicAuthenticationOptions>

The middleware BasicAuthenticationOptions which need to be configured.

Methods

InvokeAsync(HttpContext)

public override Task InvokeAsync(HttpContext context)

Parameters

context HttpContext

The context of the current request.

Returns

Task

A task that represents the execution of this middleware.