Table of Contents

Class BasicAuthenticationMiddleware

Namespace
Arc4u.OAuth2.Middleware
Assembly
Arc4u.OAuth2.AspNetCore.dll

A middleware that converts credentials into a bearer token. The credentials are read from a Basic Authorization header or, when the CertificateHeaderOptions are configured, from an encrypted header or query string parameter. A token is requested for them from the token provider designated by the ProviderId of the settings, cached in the ITokenCache, and the Authorization header of the request is replaced by Bearer <token>. Errors are logged and the request continues without change.

public class BasicAuthenticationMiddleware
Inheritance
BasicAuthenticationMiddleware
Inherited Members

Constructors

BasicAuthenticationMiddleware(RequestDelegate, ILogger<BasicAuthenticationMiddleware>, IOptionsMonitor<BasicAuthenticationSettingsOptions>, IServiceProvider)

Initializes a new instance of the BasicAuthenticationMiddleware class.

public BasicAuthenticationMiddleware(RequestDelegate next, ILogger<BasicAuthenticationMiddleware> logger, IOptionsMonitor<BasicAuthenticationSettingsOptions> options, IServiceProvider serviceProvider)

Parameters

next RequestDelegate

The next middleware of the pipeline.

logger ILogger<BasicAuthenticationMiddleware>

The logger.

options IOptionsMonitor<BasicAuthenticationSettingsOptions>

The Basic authentication settings.

serviceProvider IServiceProvider

The service provider used to check that the token provider is registered.

Exceptions

ArgumentNullException

An argument is null.

ConfigurationException

The settings are missing, have no ProviderId or designate a token provider that is not registered.

Methods

Invoke(HttpContext)

Processes the request.

public Task Invoke(HttpContext context)

Parameters

context HttpContext

The HTTP context.

Returns

Task

A task that completes when the rest of the pipeline is done.