In recent times, Microsoft has made a big splash, with the IDE releasing a new Visual Studio 2015 Preview In addition to the VIAUSL Studio 2013 Community Edition.
ASP.NET5, the user's authentication and authorization provides a very rich function, if combined with EF7, you can automatically generate the relevant database table, the call is also very convenient.
However, it is really a headache to understand such a large stack of classes about authentication authorization, or to customize the certification authority according to the specific requirements of your project. To solve this problem, there is a fundamental understanding of the mechanism of authentication and authorization, but this is not a simple matter, some concepts are also more abstract, for the sake of understanding, here I use the simplest example to demonstrate how to authenticate and authorize, and without using the EF, without using the database, Simple demo authentication and authorization itself.
To authenticate, first you have to have users, here we build a user class as follows:
<summary>
///User
///</summary> public
class HDUser
{
///<summary>
// /user Id
///</summary> public
string Id {get; set;}
<summary>
///Login
///</summary> public
string UserName {get; set;}
<summary>
///Specification user name
///</summary> public
string Normalizedusername {get; set;}
<summary>
///Password
///</summary> public
string PassWord {get; set;}
<summary>
///Hash encoded password
///</summary> public
string PasswordHash {get; set;}
<summary>
///User's role
///</summary> public
virtual icollection
Here, the fields of the HDUser class are much easier to understand, the normalizedusername difficult to understand some, can be simply considered to be the username of the upper case.
Then the role class:
<summary>
///role
///</summary> public
class Hdrole
{
///<summary>
// /role ID
///</summary> public
string Id {get; set;}
<summary>
///role name
///</summary> public
string name {get; set;}
}
With users and roles, the user role class is required to establish a relationship between the user and the role:
<summary>
///User Role Correspondence
///</summary> public
class Hduserrole
{
///< summary>
///User ID
///</summary> public
virtual string UserId {get; set;}
<summary>
///role ID
///</summary> public
virtual string Roleid {get; set;}
}
In this way, the three most basic classes we have built up.
Well, the above through a simple example of the ASP.NET5 in the user authentication and authorization (1), the next chapter to continue to introduce ASP.NET5 in the user authentication and authorization (2), the need to click between the friends to see.