ApiKeyAuthenticationOptions class

Options for API key authentication, including header names, validation, and claims issuance.

public class ApiKeyAuthenticationOptions : AuthenticationSchemeOptions, 
    IAuthenticationCommonOptions, IOpenApiAuthenticationOptions

Public Members

name description
ApiKeyAuthenticationOptions() Options for API key authentication, including header names, validation, and claims issuance.
AdditionalHeaderNames { get; set; } Other headers to try if the primary one is missing.
AllowInsecureHttp { get; set; } If true, allows API key authentication over insecure HTTP connections.
AllowQueryStringFallback { get; set; } If true, also look for the key in the query string.
ApiKeyName { get; set; } Name of to look for the API key.
ChallengeHeaderFormat { get; set; } Format for the WWW-Authenticate header in 401 responses.
ClaimPolicyConfig { get; set; } Gets or sets the claim policy configuration.
Description { get; set; }  
DisplayName { get; set; }  
DocumentationId { get; set; }  
EmitChallengeHeader { get; set; } If true, includes the WWW-Authenticate header in 401 responses.
GlobalScheme { get; set; }  
Host { get; set; }  
In { get; set; } Location to look for the API key.
IssueClaims { get; set; } After credentials are valid, this is called to add extra Claims. Parameters: HttpContext, username → IEnumerable of extra claims.
IssueClaimsCodeSettings { get; set; } Settings for the claims issuing code, if using a script.
Logger { get; set; }  
StaticApiKey { get; set; } Single expected API key (used if ValidateKey is not set).
StaticApiKeyAsBytes { get; } Gets the expected API key as a UTF-8 byte array, or null if StaticApiKey is not set.
ValidateCodeSettings { get; set; } Settings for the authentication code, if using a script.
ValidateKeyAsync { get; set; } Called to validate the raw key string. Return true if valid.
ApplyTo(…) Helper to copy values from a user-supplied ApiKeyAuthenticationOptions instance to the instance created by the framework inside AddApiKey(). Reassigning the local variable (opts = source) would not work because only the local reference changes – the framework keeps the original instance

See Also