ASP.NET Core 2 身份验证方案 [英] ASP.NET Core 2 AuthenticationSchemes

查看:36
本文介绍了ASP.NET Core 2 身份验证方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有多种身份验证方案,但我找不到有关它们的任何文档.它们有何不同?

There are several authentication schemes but I can't find any documentation on them. How do they differ?

options.DefaultScheme
options.DefaultChallengeScheme
options.DefaultForbidScheme
options.DefaultAuthenticateScheme
options.DefaultSignInScheme
options.DefaultSignOutScheme

推荐答案

来自这里

  • DefaultScheme:如果指定,所有其他默认值将回退到这个值
  • DefaultAuthenticateScheme:如果指定,AuthenticateAsync() 将使用这个方案,还有UseAuthentication() 添加的 AuthenticationMiddleware 将使用这个自动设置 context.User 的方案.(对应于自动身份验证)
  • DefaultChallengeScheme 如果指定,ChallengeAsync() 将使用此方案,[授权] 与策略不指定方案也会使用这个
  • 使用
  • DefaultSignInScheme通过 SignInAsync() 以及所有远程身份验证方案,如Google/Facebook/OIDC/OAuth,通常会设置为 cookie.
  • DefaultSignOutScheme 由 SignOutAsync() 使用,回退到 DefaultSignInScheme
  • DefaultForbidScheme 被 ForbidAsync() 使用,回退到 DefaultChallengeScheme
  • DefaultScheme: if specified, all the other defaults will fallback to this value
  • DefaultAuthenticateScheme: if specified, AuthenticateAsync() will use this scheme, and also the AuthenticationMiddleware added by UseAuthentication() will use this scheme to set context.User automatically. (Corresponds to AutomaticAuthentication)
  • DefaultChallengeScheme if specified, ChallengeAsync() will use this scheme, [Authorize] with policies that don't specify schemes will also use this
  • DefaultSignInScheme is used by SignInAsync() and also by all of the remote auth schemes like Google/Facebook/OIDC/OAuth, typically this would be set to a cookie.
  • DefaultSignOutScheme is used by SignOutAsync() falls back to DefaultSignInScheme
  • DefaultForbidScheme is used by ForbidAsync(), falls back to DefaultChallengeScheme

因此,您指定哪个 认证方案,在IAuthenticationService

So, you specify, which authentication scheme, is used in corresponding methods in IAuthenticationService

这篇关于ASP.NET Core 2 身份验证方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆