This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class ApikeyAuth(IOptionsMonitor<AuthenticationSchemeOptions> options, | |
ILoggerFactory logger, | |
UrlEncoder encoder, | |
IConfiguration config) | |
: AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder) | |
{ | |
internal const string SchemeName = "ApiKey"; | |
internal const string HeaderName = "x-api-key"; | |
readonly string _apiKey = config["Auth:ApiKey"] ?? throw new InvalidOperationException("Api key not set in appsettings.json"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal sealed class AddCustomHeader : IOperationProcessor | |
{ | |
public bool Process(OperationProcessorContext context) | |
{ | |
var hdrParameter = new OpenApiParameter() | |
{ | |
Name = "x-custom", | |
Kind = OpenApiParameterKind.Header, | |
IsRequired = true, | |
Type = JsonObjectType.String, |