ASP.NET Core Identity 及 Authentication 源代码
学习: asp.net core 3.x Identity : https://www.cnblogs.com/jionsoft/p/12326788.html
《asp.net core 3.x 身份验证-1涉及到的概念》、《asp.net core 3.x 身份验证-2启动阶段的配置》、《asp.net core 3.x 身份验证-3cookie身份验证原理》
《ASP.NET Core Identity 实战(1、2、3)》、《ASP.NET Core 之 Identity 入门(一)、(二)》
https://github.com/dotnetcore 《ASP.NET Core 运行原理解剖[5]:Authentication》
------------------------------------------------------------------------------------------------------------------------------------
Aspnet Core 的启动类 Startup 配置有下列代码:查看源代码
,扩展方法定义:AddIdentity<TUser,TRole>(IServiceCollection) , 可以只有用户 AddIdentityCore<TUser>(IServiceCollection),角色另加。
或 AddIdentity<TUser,TRole>(IServiceCollection, Action<IdentityOptions>) 或 AddIdentityCore<TUser>(IServiceCollection, Action<IdentityOptions>)
// AddIdentity 源代码: https://github.com/dotnet/aspnetcore/blob/v3.1.2/src/Identity/Extensions.Core/src/IdentityServiceCollectionExtensions.cs ( 扩展方法:AddIdentityCore<TUser> )
另一个扩展(区别?):https://github.com/dotnet/aspnetcore/blob/v3.1.2/src/Identity/Core/src/IdentityServiceCollectionExtensions.cs ( 扩展方法:AddIdentity<TUser, TRole> )
services.AddIdentity<ApplicationUser, IdentityRole<Guid>>()
.AddRoles<IdentityRole<Guid>>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddDefaultIdentity 是在 ASP.NET Core 2.1 中引入的。 调用 AddDefaultIdentity
类似于调用以下内容:
- AddIdentity ( 实际是:AddIdentityCore<TUser> (o =>{o.Stores.MaxLengthForKeys = 128;configureOptions?.Invoke(o);}) )
- AddDefaultUI
- AddDefaultTokenProviders
有关详细信息,请参阅AddDefaultIdentity 源。
IdentityUI 源代码所在: https://github.com/dotnet/aspnetcore/tree/release/3.1/src/Identity/UI/src
https://github.com/dotnet/aspnetcore/tree/release/3.1/src/Identity/UI/src/Areas/Identity/Pages/V4
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
一文章解释: AddIdentity与AddIdentityCore 、AddDefaultIdentity 的区别 : https://www.it1352.com/1768289.html