ASP.NET Core Identity Core Knowledge

Key concept

  • Claims: represent some user information key-value pairs , such as name: Joe Smith, Age: 25, Address: Beijing Zhongguancun ......
  • ClaimsIdentity: represents a / an identity proof, or you directly understood as identity cards. It is composed of a plurality of Claim.
  • ClaimsPrincipal: Generally speaking, a person will have multiple identities, such as a husband, student, teacher ......, there will be a corresponding number of "identification" (that is, proof of identity documents): marriage certificate, student card, teacher card, then you need to have a container to carry these documents, and it is: ClaimsPrincipal , how to translate the word it? We first look at the principal meaning of the term: the head of the person in charge; the main actor, the protagonist; [method] principal parties; principal; therefore temporarily called it: documents the parties , but always felt strange, so we change it, call it a document holder ; in addition, I think ClaimsPrincipal the class name should be called into ClaimsIdentityPrincipal, may be for purposes of simplicity, only shorthand.

Core interface and middleware

  • IAuthenticationHandler: For a particular embodiment, the processor creates the authentication process for each request. It is an interface, only four methods: AuthenticateAsync (), ChallengeAsync, ForbidAsync, InitializeAsync. If you need to override things related to certification, then implement this interface.
  • Authentication Middleware: The Middleware, wrote an abstract class AuthenticationHandler, the initial realization of IAuthenticationHandler, the core function of the specific class to achieve downstream to complete.

 

 

asp.net identity UserSecurityStamp role

UserSecurityStamp is mainly used for security-related information for the user to make a snapshot. Using asp.net identity of CreateAsync (TUser user) to create a user's time, if opened SupportsUserSecurityStamp it will generate a UserSecurityStamp's claim to the user's claims to go. Scenario, if that user changed the password or modify the role and exit it comes to safety-related user, this database when this value will change. If you want to read browser cookie to do auto-login account password, can be compared with this value and the value of the database to detect the cookie, so the user can log back in to update cookie, or some other operation to empty the cache and so on.

 

 

 

To be continued ......

Guess you like

Origin www.cnblogs.com/dmyang/p/11431542.html