學習: 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