// C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\7.0.5\Microsoft.AspNetCore.Authentication.dll
// Microsoft.AspNetCore.Authentication, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
https://www.nuget.org/packages/Microsoft.AspNetCore.App.Ref/7.0.5
This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/d47e49e9c1e173ac90821f7e89cc38e710274241
/// <summary>
/// Registers services required by authentication services.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
/// <returns>A <see cref="AuthenticationBuilder"/> that can be used to further configure authentication.</returns>
public static AuthenticationBuilder AddAuthentication(this IServiceCollection services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
services.AddAuthenticationCore();
services.AddDataProtection();
services.AddWebEncoders();
services.TryAddSingleton<ISystemClock, SystemClock>();
services.TryAddSingleton<IAuthenticationConfigurationProvider, DefaultAuthenticationConfigurationProvider>();
return new AuthenticationBuilder(services);
}
/// <summary>
/// Registers services required by authentication services. <paramref name="defaultScheme"/> specifies the name of the
/// scheme to use by default when a specific scheme isn't requested.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
/// <param name="defaultScheme">The default scheme used as a fallback for all other schemes.</param>
/// <returns>A <see cref="AuthenticationBuilder"/> that can be used to further configure authentication.</returns>
public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, string defaultScheme)
=> services.AddAuthentication(o => o.DefaultScheme = defaultScheme);
/// <summary>
/// Registers services required by authentication services and configures <see cref="AuthenticationOptions"/>.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
/// <param name="configureOptions">A delegate to configure <see cref="AuthenticationOptions"/>.</param>
/// <returns>A <see cref="AuthenticationBuilder"/> that can be used to further configure authentication.</returns>
public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, Action<AuthenticationOptions> configureOptions)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
if (configureOptions == null)
{
throw new ArgumentNullException(nameof(configureOptions));
}
var builder = services.AddAuthentication();
services.Configure(configureOptions);
return builder;
}
标签:used,AspNetCore,authentication,services,AddAuthentication,configureOptions From: https://www.cnblogs.com/chucklu/p/17572122.html