Table of Contents

Class ApiKeySentinelOptions

Namespace
Cuemon.AspNetCore.Http.Headers
Assembly
Cuemon.AspNetCore.dll

Configuration options for ApiKeySentinelMiddleware and related.

public class ApiKeySentinelOptions : IValidatableParameterObject, IParameterObject
Inheritance
Object
ApiKeySentinelOptions
Implements

Constructors

ApiKeySentinelOptions()

Initializes a new instance of the ApiKeySentinelOptions class.

public ApiKeySentinelOptions()

Remarks

The following table shows the initial property values for an instance of UserAgentSentinelOptions.

PropertyInitial Value
HeaderNameXApiKey
AllowedKeysnew List{string}();
GenericClientMessageThe requirements of the request was not met.
GenericClientStatusCodeSystem.Net.HttpStatusCode.BadRequest
ForbiddenMessageThe API key specified was rejected.
ResponseHandlerA System.Net.Http.HttpResponseMessage initialized to either a HTTP status code 400 or 403 and a body of either GenericClientMessage or ForbiddenMessage.
UseGenericResponsefalse

Properties

AllowedKeys

Gets or sets a list of whitelisted API keys.

public IList<string> AllowedKeys { get; set; }

Property Value

IList<String>

A list of whitelisted API keys.

BadRequestMessage

Gets or sets the generic message of a request without a valid key in AllowedKeys.

[Obsolete("This property will be removed in near future; please use GenericClientMessage instead.")]
public string BadRequestMessage { get; set; }

Property Value

String

The generic message of a request without a valid key in AllowedKeys.

ForbiddenMessage

Gets or sets the message of a request without a valid HeaderName.

public string ForbiddenMessage { get; set; }

Property Value

String

The message of a request without a valid HeaderName.

GenericClientMessage

Gets or sets the generic message of a request without a valid key in AllowedKeys.

public string GenericClientMessage { get; set; }

Property Value

String

The generic message of a request without a valid key in AllowedKeys.

GenericClientStatusCode

Gets or sets the generic status code of a request without a valid key in AllowedKeys.

public HttpStatusCode GenericClientStatusCode { get; set; }

Property Value

HttpStatusCode

The generic status code of a request without a valid key in AllowedKeys.

HeaderName

Gets or sets the name of the API key HTTP header.

public string HeaderName { get; set; }

Property Value

String

The name of the API key HTTP header.

ResponseHandler

Gets or sets the function delegate that configures the response in the form of a System.Net.Http.HttpResponseMessage.

public Func<string, HttpResponseMessage> ResponseHandler { get; set; }

Property Value

Func<String, HttpResponseMessage>

The function delegate that configures the response in the form of a System.Net.Http.HttpResponseMessage.

UseGenericResponse

Gets or sets a value indicating whether the produced ResponseHandler should be as neutral as possible.

public bool UseGenericResponse { get; set; }

Property Value

Boolean

true if the produced ResponseHandler should be as neutral as possible; otherwise, false.

Methods

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Remarks

This method is expected to throw exceptions when one or more conditions fails to be in a valid state.

Exceptions

System.InvalidOperationException

HeaderName cannot be null, empty or consist only of white-space characters - or - ResponseHandler cannot be null - or - AllowedKeys cannot be null - or - GenericClientStatusCode is not within the allowed range of an HTTP Client Error Status Code (400-499).