ASP.NET Core 2 AuthenticationSchemes

2020-06-19 07:30发布

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

1条回答
再贱就再见
2楼-- · 2020-06-19 07:37

From here

  • 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

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

查看更多
登录 后发表回答