Class AuthenticationBuilderExtensions
- Namespace
- Auth0.AspNetCore.Authentication.Api
- Assembly
- Auth0.AspNetCore.Authentication.Api.dll
Provides extension methods for AuthenticationBuilder to simplify the registration and configuration of Auth0 authentication.
public static class AuthenticationBuilderExtensions
- Inheritance
-
AuthenticationBuilderExtensions
- Inherited Members
Methods
AddAuth0ApiAuthentication(AuthenticationBuilder, IConfigurationSection, Action<JwtBearerOptions>?)
Adds Auth0 authentication for API using configuration from an IConfigurationSection with the default Auth0 scheme.
public static Auth0ApiAuthenticationBuilder AddAuth0ApiAuthentication(this AuthenticationBuilder builder, IConfigurationSection configurationSection, Action<JwtBearerOptions>? configureJwtBearer = null)
Parameters
builderAuthenticationBuilderThe AuthenticationBuilder instance to configure.
configurationSectionIConfigurationSectionThe configuration section containing Auth0 settings (Domain and Audience).
configureJwtBearerAction<JwtBearerOptions>An optional action to further configure the underlying JwtBearerOptions.
Returns
- Auth0ApiAuthenticationBuilder
An Auth0ApiAuthenticationBuilder for further configuration.
AddAuth0ApiAuthentication(AuthenticationBuilder, Action<Auth0ApiOptions>, Action<JwtBearerOptions>?)
Adds Auth0 authentication for API using a delegate to configure options programmatically with the default Auth0 scheme.
public static Auth0ApiAuthenticationBuilder AddAuth0ApiAuthentication(this AuthenticationBuilder builder, Action<Auth0ApiOptions> configureOptions, Action<JwtBearerOptions>? configureJwtBearer = null)
Parameters
builderAuthenticationBuilderThe AuthenticationBuilder instance to configure.
configureOptionsAction<Auth0ApiOptions>An action to configure the Auth0ApiOptions.
configureJwtBearerAction<JwtBearerOptions>An optional action to further configure the underlying JwtBearerOptions.
Returns
- Auth0ApiAuthenticationBuilder
An Auth0ApiAuthenticationBuilder for further configuration.
AddAuth0ApiAuthentication(AuthenticationBuilder, Action<JwtBearerOptions>?)
Adds Auth0 authentication for API using the default Auth0 scheme.
public static Auth0ApiAuthenticationBuilder AddAuth0ApiAuthentication(this AuthenticationBuilder builder, Action<JwtBearerOptions>? configureJwtBearer = null)
Parameters
builderAuthenticationBuilderThe AuthenticationBuilder instance to configure.
configureJwtBearerAction<JwtBearerOptions>An optional action to further configure the underlying JwtBearerOptions.
Returns
- Auth0ApiAuthenticationBuilder
An Auth0ApiAuthenticationBuilder for further configuration.
AddAuth0ApiAuthentication(AuthenticationBuilder, string, IConfigurationSection, Action<JwtBearerOptions>?)
Adds Auth0 authentication for API using configuration from an IConfigurationSection with a specified authentication scheme.
public static Auth0ApiAuthenticationBuilder AddAuth0ApiAuthentication(this AuthenticationBuilder builder, string authenticationScheme, IConfigurationSection configurationSection, Action<JwtBearerOptions>? configureJwtBearer = null)
Parameters
builderAuthenticationBuilderThe AuthenticationBuilder instance to configure.
authenticationSchemestringThe authentication scheme to use for Auth0 authentication.
configurationSectionIConfigurationSectionThe configuration section containing Auth0 settings (Domain and Audience).
configureJwtBearerAction<JwtBearerOptions>An optional action to further configure the underlying JwtBearerOptions.
Returns
- Auth0ApiAuthenticationBuilder
An Auth0ApiAuthenticationBuilder for further configuration.
AddAuth0ApiAuthentication(AuthenticationBuilder, string, Action<Auth0ApiOptions>, Action<JwtBearerOptions>?)
Adds Auth0 authentication for API using a delegate to configure options programmatically with a specified authentication scheme.
public static Auth0ApiAuthenticationBuilder AddAuth0ApiAuthentication(this AuthenticationBuilder builder, string authenticationScheme, Action<Auth0ApiOptions> configureOptions, Action<JwtBearerOptions>? configureJwtBearer = null)
Parameters
builderAuthenticationBuilderThe AuthenticationBuilder instance to configure.
authenticationSchemestringThe authentication scheme to use for Auth0 authentication.
configureOptionsAction<Auth0ApiOptions>An action to configure the Auth0ApiOptions.
configureJwtBearerAction<JwtBearerOptions>An optional action to further configure the underlying JwtBearerOptions.
Returns
- Auth0ApiAuthenticationBuilder
An Auth0ApiAuthenticationBuilder for further configuration.
AddAuth0ApiAuthentication(AuthenticationBuilder, string, Action<JwtBearerOptions>?)
Adds Auth0 authentication for API using a specified authentication scheme.
Auth0ApiOptions must already be registered in the DI container via
services.Configure<Auth0ApiOptions> before calling this method.
public static Auth0ApiAuthenticationBuilder AddAuth0ApiAuthentication(this AuthenticationBuilder builder, string authenticationScheme, Action<JwtBearerOptions>? configureJwtBearer = null)
Parameters
builderAuthenticationBuilderThe AuthenticationBuilder instance to configure.
authenticationSchemestringThe authentication scheme to use for Auth0 authentication.
configureJwtBearerAction<JwtBearerOptions>An optional action to further configure the underlying JwtBearerOptions.
Returns
- Auth0ApiAuthenticationBuilder
An Auth0ApiAuthenticationBuilder for further configuration.
WithCustomDomains(Auth0ApiAuthenticationBuilder, Action<Auth0CustomDomainsOptions>?)
Configures custom domains options for Auth0 API authentication.
public static Auth0ApiAuthenticationBuilder WithCustomDomains(this Auth0ApiAuthenticationBuilder builder, Action<Auth0CustomDomainsOptions>? configureOptions = null)
Parameters
builderAuth0ApiAuthenticationBuilderThe Auth0ApiAuthenticationBuilder instance to configure.
configureOptionsAction<Auth0CustomDomainsOptions>A delegate to configure the Auth0CustomDomainsOptions for custom domains integration.
Returns
- Auth0ApiAuthenticationBuilder
The configured Auth0ApiAuthenticationBuilder instance.
Exceptions
- ArgumentNullException
Thrown when
builderis null.- InvalidOperationException
Thrown when custom domains configuration is invalid.
WithDPoP(Auth0ApiAuthenticationBuilder)
Enables DPoP (Demonstration of Proof-of-Possession) support with default configuration using the default Auth0 authentication scheme.
public static Auth0ApiAuthenticationBuilder WithDPoP(this Auth0ApiAuthenticationBuilder builder)
Parameters
builderAuth0ApiAuthenticationBuilderThe Auth0ApiAuthenticationBuilder instance to configure.
Returns
- Auth0ApiAuthenticationBuilder
The configured Auth0ApiAuthenticationBuilder instance.
WithDPoP(Auth0ApiAuthenticationBuilder, Action<DPoPOptions>)
Enables DPoP (Demonstration of Proof-of-Possession) support using the default Auth0 authentication scheme.
public static Auth0ApiAuthenticationBuilder WithDPoP(this Auth0ApiAuthenticationBuilder builder, Action<DPoPOptions> configureDPoPOptions)
Parameters
builderAuth0ApiAuthenticationBuilderThe Auth0ApiAuthenticationBuilder instance to configure.
configureDPoPOptionsAction<DPoPOptions>A delegate to configure the DPoPOptions for DPoP integration.
Returns
- Auth0ApiAuthenticationBuilder
The configured Auth0ApiAuthenticationBuilder instance.