Reputation:
In Net Core Identity Management, what is the difference between IdentityRole and IdentityUser?
public class AppIdentityRole : IdentityRole
{ }
public class AppIdentityUser : IdentityUser
{
public int Age { get; set; }
}
public class AppIdentityDbContext
: IdentityDbContext<AppIdentityUser, AppIdentityRole, string>
{
public AppIdentityDbContext(DbContextOptions<AppIdentityDbContext> options)
: base(options)
{ }
}
Upvotes: 1
Views: 5032
Reputation: 5361
Identity user: Use for authenticate ex : login user
Identity role : Use for authorization ex: Administrator (above user belongs to administrator role)
Users have roles, roles have permissions. Like create app
Upvotes: 1
Reputation: 425
IdentityUser is the ASP.NET Core MVC class that contains information about users registered in your application. It contains default properties such as username, email, password e.t.c. This class can be inherited and more properties provided.
IdentityRole is the ASP.NET Core MVC class that contains information about user roles (which are usage domains) of the IdentityUsers defined in your application.
An IdentityUser can contain many IdentityRoles and an IdentityRole can contain many IdentityUsers. Hence in your application, IdentityRoles can be used as filters for authentication where only IdentityUsers that belong to a certain IdentityRole/s can access either the class or method.
Upvotes: 0