21.121. 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
21.121.1. Inheritance
object ← AuthenticationHandler<AuthenticatorOptions> ← Authenticator
21.121.2. Implements
21.121.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()
21.121.4. Constructors
21.121.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)
21.121.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
21.121.4.1.2. Exceptions
ArmoniKException
Thrown if the authenticator is misconfigured (missing options)
21.121.5. Fields
21.121.5.1. SchemeName
Name of the scheme for this handler
public const string SchemeName = "ArmoniKAuthenticationScheme"
21.121.5.1.1. Field Value
21.121.6. Methods
21.121.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)
21.121.6.1.1. Parameters
cn string
Common name of the certificate
fingerprint string
Fingerprint of the certificate
cancellationToken CancellationToken
Cancellation token
21.121.6.1.2. Returns
A UserIdentity object which can be used in authentication, corresponding to the certificate. Null if it doesn’t correspond to any user.
21.121.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)
21.121.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
21.121.6.2.2. Returns
The impersonated user’s UserIdentity
21.121.6.2.3. Exceptions
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
21.121.6.3. HandleAuthenticateAsync()
Function called by the Authentication middleware to get the authentication ticket for the user
[UsedImplicitly]
protected override Task<AuthenticateResult> HandleAuthenticateAsync()