Table of Contents

Class AuthorizationResponseHandlerOptions

Namespace
Cuemon.Extensions.AspNetCore.Authentication
Assembly
Cuemon.Extensions.AspNetCore.Authentication.dll

Specifies options that is related to AuthorizationResponseHandler operations.

public class AuthorizationResponseHandlerOptions : AsyncOptions, IAsyncOptions, IExceptionDescriptorOptions, IValidatableParameterObject, IParameterObject
Inheritance
Object
AuthorizationResponseHandlerOptions
Implements
Inherited Members
Extension Methods

Constructors

AuthorizationResponseHandlerOptions()

Initializes a new instance of the AuthorizationResponseHandlerOptions class.

public AuthorizationResponseHandlerOptions()

Remarks

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

PropertyInitial Value
FallbackResponseHandlernew AuthorizationMiddlewareResultHandler()
SensitivityDetailsNone
AuthorizationFailureHandler
AuthorizationFailureHandler = failure =>
{
if (failure != null)
{
if (failure.FailureReasons.Any(reason => !string.IsNullOrWhiteSpace(reason.Message)))
{
return new ForbiddenException(failure.FailureReasons.Select(reason => reason.Message).ToDelimitedString(o => o.Delimiter = Environment.NewLine));
}

if (failure.FailedRequirements.Any(requirement => { var failureReason = requirement.ToString(); if (string.IsNullOrWhiteSpace(failureReason)) { return false; } return failureReason != requirement.GetType().ToString(); })) { return new ForbiddenException(failure.FailedRequirements.Select(requirement => requirement.ToString()).ToDelimitedString(o => o.Delimiter = Environment.NewLine)); } } return new ForbiddenException(); };

Properties

AuthorizationFailureHandler

Gets or sets the function delegate that provides the reason/requirement/generic message of the failed authorization.

public Func<AuthorizationFailure, HttpStatusCodeException> AuthorizationFailureHandler { get; set; }

Property Value

Func<AuthorizationFailure, HttpStatusCodeException>

The function delegate that provides the reason/requirement/generic message of the failed authorization.

FallbackResponseHandler

Gets or sets the mandatory Microsoft.AspNetCore.Authorization.IAuthorizationMiddlewareResultHandler implementation of a fallback response handler.

public IAuthorizationMiddlewareResultHandler FallbackResponseHandler { get; set; }

Property Value

IAuthorizationMiddlewareResultHandler

The mandatory Microsoft.AspNetCore.Authorization.IAuthorizationMiddlewareResultHandler implementation of a fallback response handler.

Remarks

If everything else fails; this is safeguard to keep the AuthN/AuthZ flow intact.

SensitivityDetails

Gets or sets a bitwise combination of the enumeration values that specify which sensitive details to include in the serialized result.

public FaultSensitivityDetails SensitivityDetails { get; set; }

Property Value

FaultSensitivityDetails

The enumeration values that specify which sensitive details to include in the serialized result.

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

FallbackResponseHandler cannot be null -or- AuthorizationFailureHandler cannot be null.