Class ApiKeyAuthenticationExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Identity.AspNetCore.dll
Authentication-builder extensions for the Stratara API-key scheme and the auth-scheme selector. API keys are just another ASP.NET Core scheme — the provider seam is the scheme, not a custom abstraction — so they compose with cookies, bearer tokens, and OIDC handlers.
public static class ApiKeyAuthenticationExtensions
- Inheritance
-
ApiKeyAuthenticationExtensions
- Inherited Members
Methods
AddStrataraApiKey(AuthenticationBuilder, Action<ApiKeyAuthenticationOptions>?)
Register the Stratara API-key authentication scheme
(SchemeName). Requires a registered
IApiKeyStore (for example
AddApiKeyStore<TContext>() from Stratara.Identity.EntityFrameworkCore).
public static AuthenticationBuilder AddStrataraApiKey(this AuthenticationBuilder builder, Action<ApiKeyAuthenticationOptions>? configure = null)
Parameters
builderAuthenticationBuilderThe authentication builder.
configureAction<ApiKeyAuthenticationOptions>Optional callback to configure header/query behavior.
Returns
- AuthenticationBuilder
The same builder, to enable chaining.
Examples
Reads the X-Api-Key header; the query-parameter fallback is opt-in:
services.AddAuthentication().AddStrataraApiKey();
AddStrataraAuthSchemeSelector(AuthenticationBuilder, Action<StrataraAuthSchemeSelectorOptions>?)
Register the Stratara auth-scheme selector
(SchemeName): a policy scheme that routes
each request by shape — API-key header → API-key scheme, Authorization: Bearer →
bearer scheme, everything else → the fallback (cookie) scheme. Set it as the default
scheme so mixed API/browser hosts need no per-endpoint scheme lists.
public static AuthenticationBuilder AddStrataraAuthSchemeSelector(this AuthenticationBuilder builder, Action<StrataraAuthSchemeSelectorOptions>? configure = null)
Parameters
builderAuthenticationBuilderThe authentication builder.
configureAction<StrataraAuthSchemeSelectorOptions>Optional callback to override the routed scheme names.
Returns
- AuthenticationBuilder
The same builder, to enable chaining.
Examples
builder.Services
.AddAuthentication(StrataraAuthSchemeSelectorOptions.SchemeName)
.AddStrataraApiKey()
.AddStrataraAuthSchemeSelector();