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,
and the Authorization header of the request is replaced by Bearer <token>.
The middleware does not cache the token: caching is the job of the token provider (the default Credential provider,
CredentialTokenCacheTokenProvider, caches it in the ITokenCache).
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
nextRequestDelegateThe next middleware of the pipeline.
loggerILogger<BasicAuthenticationMiddleware>The logger.
optionsIOptionsMonitor<BasicAuthenticationSettingsOptions>The Basic authentication settings.
serviceProviderIServiceProviderThe service provider used to check that the token provider is registered.
Exceptions
- ArgumentNullException
An argument is null.
- ConfigurationException
The settings are missing, have no
ProviderIdor designate a token provider that is not registered.
Methods
Invoke(HttpContext)
Processes the request.
public Task Invoke(HttpContext context)
Parameters
contextHttpContextThe HTTP context.
Returns
- Task
A task that completes when the rest of the pipeline is done.