Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core 2 AuthenticationSchemes

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
like image 666
Joffrey Avatar asked Sep 14 '17 15:09

Joffrey


1 Answers

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, is used in corresponding methods in IAuthenticationService

like image 57
Yurii N. Avatar answered Oct 06 '22 17:10

Yurii N.