22.113. 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

22.113.1. Inheritance

objectAuthenticationHandler<AuthenticatorOptions>Authenticator

22.113.2. Implements

IAuthenticationHandler

22.113.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()

22.113.4. Constructors

22.113.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)

22.113.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

22.113.4.1.2. Exceptions

ArmoniKException

Thrown if the authenticator is misconfigured (missing options)

22.113.5. Fields

22.113.5.1. SchemeName

Name of the scheme for this handler

public const string SchemeName = "ArmoniKAuthenticationScheme"

22.113.5.1.1. Field Value

string

22.113.6. Methods

22.113.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)

22.113.6.1.1. Parameters

cn string

Common name of the certificate

fingerprint string

Fingerprint of the certificate

cancellationToken CancellationToken

Cancellation token

22.113.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.

22.113.6.2. GetImpersonatedIdentityAsync(ClaimsPrincipal, int?, string?, CancellationToken)

Get the UserIdentity attempting to be impersonated by the user

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

22.113.6.2.1. Parameters

baseIdentity ClaimsPrincipal

UserIdentity trying to impersonate

impersonationId int?

Id of the user being impersonated

impersonationUsername string?

Username of the user being impersonated

cancellationToken CancellationToken

Cancellation token

22.113.6.2.2. Returns

Task<ClaimsPrincipal>

The impersonated user’s UserIdentity

22.113.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

22.113.6.3. HandleAuthenticateAsync()

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

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

22.113.6.3.1. Returns

Task<AuthenticateResult>