AddAuthentication
// 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;
}
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2021-07-21 System.Web.Http.dll 所在的NuGet
2019-07-21 一个可乐瓶自制捕蟑螂神器
2019-07-21 compare across commits online
2015-07-21 When to use DataContract and DataMember attributes?
2015-07-21 Learning WCF Chapter2 Data Contracts
2014-07-21 C#中线程的使用[Thread in C#]