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 配置有下列代码:查看源代码  dotnet/aspnetcore

以及官方的文档解释  https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/identity?view=aspnetcore-3.1&tabs=visual-studio 

扩展方法定义: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 类似于调用以下内容:

有关详细信息,请参阅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

 

posted @ 2020-02-29 20:39  Hopesun  阅读(766)  评论(1编辑  收藏  举报