Skip to content

Latest commit

 

History

History
51 lines (42 loc) · 2.82 KB

README.md

File metadata and controls

51 lines (42 loc) · 2.82 KB

Mvc Role Manager

This project provides a functionality that can authorize roles to controllers/actions dynamically via a web page.

It is using Asp.net MVC, Identity framework, OAuth security, Token/Claims based authentication/authorization, Owin, Web Api2 and Angular.js.

Asp.net mvc provides an authorization featuers based on roles/users for controllers and actions. But the roles/actions are hard coded in the code. For example:

[Authorize(Roles = "Admin")] public Class MyController : Controller {

}

Only Admin role is authorized to use this controller. It's hardcoded.

The project will provide a generic function with a web page that authorize roles/uers for controllers and actions. These setinggs will be saved to database or a file.

  • Front end stack

    Angular.js, bootstrap, angular ui bootstrap, angular schema form. Try to avoid jquery.
  • Back end stack

    ASP.NET mvc, web api 2, entityframe work 6, identity framework
  • Database

    SQL server. Mysql and more types of databases later.

What kind of projects can use it?

If you are going to create a new project, your project can use it as scaffolding and start from there. If you have an existing project, which uses ASP.NET MVC/WEB API as well as asp.net identity framework(Token/Claim based authentication), you can integrate Mvc Role Manager into your project very easily. All you have to do is:
  • Add config.Filters.Add(new ApiAuthoraiztionFilter()); to App_Start\WebApiConfig.cs file to enable web api authorization;
  • Add filters.Add(new HandleErrorAttribute()); to App_Start\FilterConfig.cs to enable MVC web page authorization;
  • Copy Areas/RoleManager folder to the root of your project. MvcRoleManager resides only in this folder .
  • The project will create two new tables, Action and ActionRoles. Action stores actions of controllers that need to be authorized; ActionRoles have the links between Actions and Roles.
  • Configuration page locates at http://yourproject/RoleManager/ .
    SCREENSHOT SCREENSHOT1

How to use

  • Download the code and open in Visual Studio.
  • Restore dependency files and change the database connection string in web.config.
  • Build the solution and you are good for a test ride.

Any questions, create an issue or email: [email protected].