ASP.NET Core - Permission Based Authorization - Complete User Management Guide

preview_player
Показать описание
Download source code 👇👇🙂

In this video, we will implement a complete Permission-Based Authorization in ASP.NET Core using .NET 5 and Microsoft Identity package. We built the entire system from scratch to control the level of authorization on the basis of User Roles. The SuperAdmin will be able to control the permission and add new roles as well. This is a neat way to secure your ASP.NET Core Web Applications from users with limited permissions.

What’s Role-Based Authorization?
Role-Based Authorization in ASP.NET Core is a way to restrict/allow users to access specific resources in the application. The [Authorize] attribute when declared in the Controller or any action methods, restricts users bases on his/her role settings.
For instance, the Delete method is accessible only to users who have the Role ‘SuperAdmin’ assigned to them, and so on. You are getting the point, yeah?

When run the application , with SuperAdmin credentials. Navigate to /products. As excepted, the superadmin has access to all the features of the Product module

Features :
- User List – To display all the registered users
- Roles List – To Display / Add Roles
- User – Roles Management – To assign various roles to each user.
- Default Seeding – Seed default roles and users on application startup
- Permission Management – Role-based permissions controller
- Dummy Products Management – To Create / Read / Modify Products (Note that this will not be implemented completely). The aim is to dynamically restrict users based on their roles from various actions on the Product Entity. For instance, only Admins can modify the data.

asp net core authorization policy from database
mvc permissions
mvc permissions roles
mvc permission based security
mvc permission controller
spring mvc permissions
mvc menu permission
mvc app permissions
permission mvc
permission based mvc
manage user roles in asp net core identity

mvc authorization filter
mvc authorizationcontext
mvc authorization example
mvc authorization failure redirect
mvc authorization attribute
mvc authorization roles
mvc authorization header
mvc authorization c#
mvc authorization attribute example
mvc authorization allow users
mvc authorization and roles implementation
mvc area authorization
mvc action authorization
mvc authorize by role
mvc role based authorization
mvc claims based authorization
mvc authentication and authorization best practices
mvc policy based authorization
mvc role based authentication sample
mvc authorize controller
mvc authorize custom roles
mvc authorize custom
Рекомендации по теме
Комментарии
Автор

Can you make a small overview video on how this system actually works? Like I have worked with Identity but It is still hard for me to grasp what you showed here. Behind the scenes how roles and claims are stored and mapped to each other etc. That would be a super helpful video. I have worked with static roles and authorization but in the industry, most people use dynamic and modular roles like what you have shown here but there are no good resources out there that shows how it works

Edit: how do you check in the back end if a role is authorized or not? so for instance, we use [Authorize(Role)] above an API method to check for authorization but since the roles are modular in this case, how do you check for Authorization in the back end?

rutvikpanchal
Автор

Hey, kindly do the same in blazor web assembly

ariyotech
Автор

What if we assign more then one role to the user?

Uzair_Anwar
Автор

How come you're using email for login id?

rogercute
Автор

Bro how can you write code like this? Without testing. Amazing skills

tesali
Автор

Amazing video. Do you have any course(s) video on this subject?

issakahniiarmahtagoe
Автор

Hi.
I have a problem with my project.
In the file Startup.cs, the code:
services.AddIdentity<IdentityUser<int>, IdentityRole>()

.AddDefaultUI()
.AddDefaultTokenProviders();
is giving me the following error:
System.ArgumentException: 'GenericArguments[1], 'Microsoft.AspNetCore.Identity.IdentityRole', on 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9[TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim]' violates the constraint of type 'TRole'.'

What am I doing wrong, please?

celiofaustino