Fluentsecurity is a class library to secure your ASP. Website
First, Install
Second, Config into Global.asax
Private voidSetPolicy () {//Set SecuritySecurityconfigurator.configure (config ={config. Getauthenticationstatusfrom (()=Userverify.isuserauth ()); Config. for<HomeController>(). Ignore (); Config. for<UsersController> (). Addpolicy (NewRolepolicy (roles.admin)); Config. for<TestPlanController> (). Addpolicy (NewRolepolicy (Roles.admin, Roles.lead, roles.guest)); Config. for<CollectionsController> (). Addpolicy (NewRolepolicy (Roles.admin, Roles.lead)); Config. for<TemplatesController> (). Addpolicy (NewRolepolicy (Roles.lead, roles.admin)); Config. for<AppsController> (). Addpolicy (NewRolepolicy (Roles.admin, Roles.lead, Roles.guest, Roles.dev)); Config. for<GauntletController> (). Addpolicy (NewRolepolicy (Roles.admin, Roles.lead, Roles.dev)); //CONFIG. For<admincontroller> (). Addpolicy (New Rolepolicy (roles.admin));Config. For<toolscontroller> (). Addpolicy (NewRolepolicy (roles.admin)); }); GLOBALFILTERS.FILTERS.ADD (NewHandlesecurityattribute (),0); }
View Code
Third, Tutorial address
Http://blog.mariusschulz.com/2011/12/05/securing-an-aspnet-mvc-application-using-fluentsecurity
ASP. NET Security API---fluentsecurity