Asp.net core asp.net核心:AuthenticationHandler和IAAuthenticationService的关系如何?

Asp.net core asp.net核心:AuthenticationHandler和IAAuthenticationService的关系如何?,asp.net-core,authentication,Asp.net Core,Authentication,我试图理解asp.net核心身份验证 我看到,为了处理自定义模式,可以使用从AuthenticationHandler派生的类: services.AddAuthentication("BasicAuthentication") .AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);

我试图理解asp.net核心身份验证

我看到,为了处理自定义模式,可以使用从AuthenticationHandler派生的类:

services.AddAuthentication("BasicAuthentication")
            .AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
services.AddAuthentication(“基本验证”)
.AddScheme(“基本验证”,null);
但是这个类与IAAuthenticationService有什么关系呢?默认实现是否在某个点调用处理程序


谢谢

调用函数
AddScheme()
时,它会执行以下操作:

  • 在IServiceCollection中使用其具体类型注册处理程序(即,在本例中,它等效于
    services.AddTransient()
  • 在IServiceCollection中使用Scheme名称配置选项(即,在本例中,如果您喜欢在代码中挖掘,则类似于
    services.AddOptions)
  • iaauthenticationservice
    默认实现
    AuthenticationService
    当其功能
    authenticateSync()时
    使用一个特定的方案调用,它将使用我上面解释的这个映射解析特定的处理程序。更具体地说,它将使用
    iaAuthenticationHandlerProvider
    对于这个作业,它的默认实现是
    AuthenticationHandlerProvider
    它有一个函数
    [GetHandlerAsync()][2]
    搜索(方案/处理程序)的映射并返回与方案匹配的适当处理程序

    当然,这是身份验证处理程序在后台使用身份验证方案和处理程序所做的简化版本,但我希望它能回答您的问题^^