17.119. Class Authenticator

Namespace: ArmoniK.Core.Common.Auth.Authentication
Assembly: ArmoniK.Core.Common.dll

Authentication handler used in the authentication middleware

public class Authenticator : AuthenticationHandler<AuthenticatorOptions>, IAuthenticationHandler

17.119.1. Inheritance

objectAuthenticationHandler<AuthenticatorOptions>Authenticator

17.119.2. Implements

IAuthenticationHandler

17.119.3. Inherited Members

AuthenticationHandler<AuthenticatorOptions>.InitializeAsync(AuthenticationScheme, HttpContext), AuthenticationHandler<AuthenticatorOptions>.InitializeEventsAsync(), AuthenticationHandler<AuthenticatorOptions>.CreateEventsAsync(), AuthenticationHandler<AuthenticatorOptions>.InitializeHandlerAsync(), AuthenticationHandler<AuthenticatorOptions>.BuildRedirectUri(string), AuthenticationHandler<AuthenticatorOptions>.ResolveTarget(string?), AuthenticationHandler<AuthenticatorOptions>.AuthenticateAsync(), AuthenticationHandler<AuthenticatorOptions>.HandleAuthenticateOnceAsync(), AuthenticationHandler<AuthenticatorOptions>.HandleAuthenticateOnceSafeAsync(), AuthenticationHandler<AuthenticatorOptions>.HandleAuthenticateAsync(), AuthenticationHandler<AuthenticatorOptions>.HandleForbiddenAsync(AuthenticationProperties), AuthenticationHandler<AuthenticatorOptions>.HandleChallengeAsync(AuthenticationProperties), AuthenticationHandler<AuthenticatorOptions>.ChallengeAsync(AuthenticationProperties?), AuthenticationHandler<AuthenticatorOptions>.ForbidAsync(AuthenticationProperties?), AuthenticationHandler<AuthenticatorOptions>.Scheme, AuthenticationHandler<AuthenticatorOptions>.Options, AuthenticationHandler<AuthenticatorOptions>.Context, AuthenticationHandler<AuthenticatorOptions>.Request, AuthenticationHandler<AuthenticatorOptions>.Response, AuthenticationHandler<AuthenticatorOptions>.OriginalPath, AuthenticationHandler<AuthenticatorOptions>.OriginalPathBase, AuthenticationHandler<AuthenticatorOptions>.Logger, AuthenticationHandler<AuthenticatorOptions>.UrlEncoder, AuthenticationHandler<AuthenticatorOptions>.Clock, AuthenticationHandler<AuthenticatorOptions>.TimeProvider, AuthenticationHandler<AuthenticatorOptions>.OptionsMonitor, AuthenticationHandler<AuthenticatorOptions>.Events, AuthenticationHandler<AuthenticatorOptions>.ClaimsIssuer, AuthenticationHandler<AuthenticatorOptions>.CurrentUri, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

17.119.4. Constructors

17.119.4.1. Authenticator(IOptionsMonitor<AuthenticatorOptions>, ILoggerFactory, UrlEncoder, IAuthenticationTable, AuthenticationCache)

Creates an authentication handler

public Authenticator(IOptionsMonitor<AuthenticatorOptions> options, ILoggerFactory loggerFactory, UrlEncoder encoder, IAuthenticationTable authTable, AuthenticationCache cache)

17.119.4.1.1. Parameters

options IOptionsMonitor<AuthenticatorOptions>

Options (See )

loggerFactory ILoggerFactory

Logger factory (See )

encoder UrlEncoder

Url Encoder (See )

authTable IAuthenticationTable

Authentication table storage

cache AuthenticationCache

Authentication cache

17.119.4.1.2. Exceptions

ArmoniKException

Thrown if the authenticator is misconfigured (missing options)

17.119.5. Fields

17.119.5.1. SchemeName

Name of the scheme for this handler

public const string SchemeName = "ArmoniKAuthenticationScheme"

17.119.5.1.1. Field Value

string

17.119.6. Methods

17.119.6.1. GetIdentityFromCertificateAsync(string, string, CancellationToken)

Get the UserIdentity from the CN and Fingerprint of a certificate

public Task<ClaimsPrincipal?> GetIdentityFromCertificateAsync(string cn, string fingerprint, CancellationToken cancellationToken = default)

17.119.6.1.1. Parameters

cn string

Common name of the certificate

fingerprint string

Fingerprint of the certificate

cancellationToken CancellationToken

Cancellation token

17.119.6.1.2. Returns

Task<ClaimsPrincipal?>

A UserIdentity object which can be used in authentication, corresponding to the certificate. Null if it doesn’t correspond to any user.

17.119.6.2. GetImpersonatedIdentityAsync(ClaimsPrincipal, string?, string?, CancellationToken)

Get the UserIdentity attempting to be impersonated by the user

public Task<ClaimsPrincipal> GetImpersonatedIdentityAsync(ClaimsPrincipal baseIdentity, string? impersonationId, string? impersonationUsername, CancellationToken cancellationToken = default)

17.119.6.2.1. Parameters

baseIdentity ClaimsPrincipal

UserIdentity trying to impersonate

impersonationId string?

Id of the user being impersonated

impersonationUsername string?

Username of the user being impersonated

cancellationToken CancellationToken

Cancellation token

17.119.6.2.2. Returns

Task<ClaimsPrincipal>

The impersonated user’s UserIdentity

17.119.6.2.3. Exceptions

AuthenticationException

Thrown when both id and username are missing, the impersonated user doesn’t exist, or the impersonating user doesn’t have the permissions to impersonate the specified user

17.119.6.3. HandleAuthenticateAsync()

Function called by the Authentication middleware to get the authentication ticket for the user

[UsedImplicitly]
protected override Task<AuthenticateResult> HandleAuthenticateAsync()

17.119.6.3.1. Returns

Task<AuthenticateResult>