Table of Contents

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

builder AuthenticationBuilder

The AuthenticationBuilder instance to configure.

configurationSection IConfigurationSection

The configuration section containing Auth0 settings (Domain and Audience).

configureJwtBearer Action<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

builder AuthenticationBuilder

The AuthenticationBuilder instance to configure.

configureOptions Action<Auth0ApiOptions>

An action to configure the Auth0ApiOptions.

configureJwtBearer Action<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

builder AuthenticationBuilder

The AuthenticationBuilder instance to configure.

configureJwtBearer Action<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

builder AuthenticationBuilder

The AuthenticationBuilder instance to configure.

authenticationScheme string

The authentication scheme to use for Auth0 authentication.

configurationSection IConfigurationSection

The configuration section containing Auth0 settings (Domain and Audience).

configureJwtBearer Action<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

builder AuthenticationBuilder

The AuthenticationBuilder instance to configure.

authenticationScheme string

The authentication scheme to use for Auth0 authentication.

configureOptions Action<Auth0ApiOptions>

An action to configure the Auth0ApiOptions.

configureJwtBearer Action<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

builder AuthenticationBuilder

The AuthenticationBuilder instance to configure.

authenticationScheme string

The authentication scheme to use for Auth0 authentication.

configureJwtBearer Action<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

builder Auth0ApiAuthenticationBuilder

The Auth0ApiAuthenticationBuilder instance to configure.

configureOptions Action<Auth0CustomDomainsOptions>

A delegate to configure the Auth0CustomDomainsOptions for custom domains integration.

Returns

Auth0ApiAuthenticationBuilder

The configured Auth0ApiAuthenticationBuilder instance.

Exceptions

ArgumentNullException

Thrown when builder is 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

builder Auth0ApiAuthenticationBuilder

The 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

builder Auth0ApiAuthenticationBuilder

The Auth0ApiAuthenticationBuilder instance to configure.

configureDPoPOptions Action<DPoPOptions>

A delegate to configure the DPoPOptions for DPoP integration.

Returns

Auth0ApiAuthenticationBuilder

The configured Auth0ApiAuthenticationBuilder instance.