📜 ⬆️ ⬇️

ASP.NET 5 Identity 3 and new authentication / authorization toolkit

Life in Las Vegas is not limited to gambling. Despite the glory of the gambling capital, events are taking place here entirely from other spheres of life. In particular, the annual DEVIntersection conference, which this year was attended by a team of our developers. And here we want to talk about all the most important and interesting things that they learned at the conference.

ASP.NET 5 Changes


In the context of ASP.NET 5, all components of the stack have been updated or completely rewritten. Changes are not spared and ASP.NET Identity, which can not but rejoice. In particular, the authorization system has been updated, and these are really qualitative changes (IMHO). Next, we consider exactly what changes were made to the authentication and authorization systems.

ASP.NET Identity


On Habré was already an overview article on the topic of ASP.NET Identity, so skip the introductory part.

ASP.NET Identity provides tools for working with users and their authentication. This system consists of the Microsoft.AspNet.Identity library with a description of the main classes and abstractions in the form of user store interfaces, etc. Microsoft.AspNet.Identity.EntityFramework is a library that contains the user / role implementation and repositories based on the Entity Framework 7.
')
The first thing you want to pay attention to is the lack of interfaces for users and roles. Identity does not dictate to us what our user should be. When setting up, it is enough to indicate which user classes and roles we want to use. This is achieved due to the fact that the UserManager class delegates the user’s read / write properties to the repository. For example, such operations of the UserManager class as GetUserName , SetUserName and ChangePassword
ChangePassword
lead to calls of the same type from UserStore.

The repositories of users and roles do not have to describe all possible operations. In one application, a user only needs to have a name, password and the ability to log in using them, while in the other one it is necessary to have various authentication options and support a lot of other possibilities. For our application, we just need to choose the appropriate storage interface and implement only it.

List of user storage interfaces:

Source: https://habr.com/ru/post/273753/


All Articles