Table of Contents

Class AuthenticationServiceExtensions

Namespace
ProjectTemplate.Web.Authentication.Extensions
Assembly
ProjectTemplate.Web.dll

Provides extension methods for registering and applying application authentication services.

public static class AuthenticationServiceExtensions
Inheritance
AuthenticationServiceExtensions
Inherited Members

Fields

AuthenticationCookieName

The authentication cookie name used when the Development-only insecure HTTP override is active.

public const string AuthenticationCookieName = ".ProjectTemplate.Web.Authentication"

Field Value

string

HostPrefixedAuthenticationCookieName

The authentication cookie name used when the cookie is always sent with the Secure attribute.

public const string HostPrefixedAuthenticationCookieName = "__Host-ProjectTemplate.Web.Authentication"

Field Value

string

Methods

AddApplicationAuthentication(IServiceCollection, IConfiguration)

Adds application authentication services based on configuration using the secure cookie policy without an environment-specific plain HTTP override.

public static IServiceCollection AddApplicationAuthentication(this IServiceCollection services, IConfiguration configuration)

Parameters

services IServiceCollection

The service collection to add authentication services to.

configuration IConfiguration

The application configuration source.

Returns

IServiceCollection

The same IServiceCollection instance for chaining.

AddApplicationAuthentication(IServiceCollection, IConfiguration, IHostEnvironment?)

Adds application authentication services based on configuration and the current hosting environment.

public static IServiceCollection AddApplicationAuthentication(this IServiceCollection services, IConfiguration configuration, IHostEnvironment? environment)

Parameters

services IServiceCollection

The service collection to add authentication services to.

configuration IConfiguration

The application configuration source.

environment IHostEnvironment

The current hosting environment.

Returns

IServiceCollection

The same IServiceCollection instance for chaining.

UseApplicationAuthentication(IApplicationBuilder)

Applies application authentication middleware when authentication is enabled.

public static IApplicationBuilder UseApplicationAuthentication(this IApplicationBuilder app)

Parameters

app IApplicationBuilder

The application builder.

Returns

IApplicationBuilder

The same IApplicationBuilder instance for chaining.