Table of Contents

Authenticate Method

Definition

Namespace
Cuemon.AspNetCore.Authentication
Assemblies
Cuemon.AspNetCore.Authentication.dll
Source
src/Cuemon.AspNetCore.Authentication/Authenticator.cs

Authenticate<T>(HttpContext, bool, Func<HttpContext, string, T>, TesterFunc<HttpContext, T, ConditionalValue<ClaimsPrincipal>, bool>)

Provides a generic way to make authentication requests using the specified context.

public static ConditionalValue<ClaimsPrincipal> Authenticate<T>(HttpContext context, bool requireSecureConnection, Func<HttpContext, string, T> authorizationParser, TesterFunc<HttpContext, T, ConditionalValue<ClaimsPrincipal>, bool> principalParser)

Parameters

context HttpContext

The context of the ASP.NET application.

requireSecureConnection bool

When true, the HTTP connection is required to use secure sockets (that is, HTTPS); when false no requirement is enforced.

authorizationParser Func<HttpContext, string, T>

The function delegate that will parse the authorization header of a web request and return the credentials of T.

principalParser TesterFunc<HttpContext, T, ConditionalValue<ClaimsPrincipal>, bool>

The function delegate that will parse the credentials of T returned from authorizationParser and if successful returns a ClaimsPrincipal object.

Returns

ConditionalValue<ClaimsPrincipal>

A ClaimsPrincipal if principalParser was successful.

Type Parameters

T

The type of the credentials returned from authorizationParser and passed to principalParser.

Exceptions

SecurityException

Authorized failed for the request.