Class ApiKeyAuthenticationHandler
- Namespace
- Stratara.Identity.AspNetCore.Authentication
- Assembly
- Stratara.Identity.AspNetCore.dll
ASP.NET Core authentication handler for Stratara API keys — a standard scheme, so it
composes with cookie/bearer schemes via [Authorize(AuthenticationSchemes=...)] or the
Stratara auth-scheme selector.
public sealed class ApiKeyAuthenticationHandler : AuthenticationHandler<ApiKeyAuthenticationOptions>, IAuthenticationHandler
- Inheritance
-
ApiKeyAuthenticationHandler
- Implements
- Inherited Members
- Extension Methods
Remarks
On success the ticket carries the name-identifier (the bound user for personal access
tokens, the key id for machine keys) and the stratara:tenant_id claim — exactly the
claims the session-context middleware reads, so an API-key request flows through session
context, membership roles, and permission resolution like any human sign-in. Validation is
fail-closed (unknown/revoked/expired keys fail authentication); no permissions are embedded
in the ticket.
Constructors
ApiKeyAuthenticationHandler(IOptionsMonitor<ApiKeyAuthenticationOptions>, ILoggerFactory, UrlEncoder, IApiKeyStore)
ASP.NET Core authentication handler for Stratara API keys — a standard scheme, so it
composes with cookie/bearer schemes via [Authorize(AuthenticationSchemes=...)] or the
Stratara auth-scheme selector.
public ApiKeyAuthenticationHandler(IOptionsMonitor<ApiKeyAuthenticationOptions> options, ILoggerFactory logger, UrlEncoder encoder, IApiKeyStore apiKeyStore)
Parameters
optionsIOptionsMonitor<ApiKeyAuthenticationOptions>The scheme options.
loggerILoggerFactoryThe ASP.NET authentication logger factory.
encoderUrlEncoderURL encoder required by the base handler.
apiKeyStoreIApiKeyStoreThe store validating presented keys.
Remarks
On success the ticket carries the name-identifier (the bound user for personal access
tokens, the key id for machine keys) and the stratara:tenant_id claim — exactly the
claims the session-context middleware reads, so an API-key request flows through session
context, membership roles, and permission resolution like any human sign-in. Validation is
fail-closed (unknown/revoked/expired keys fail authentication); no permissions are embedded
in the ticket.
Methods
HandleAuthenticateAsync()
Allows derived types to handle authentication.
protected override Task<AuthenticateResult> HandleAuthenticateAsync()