roles

asp.net membership - how to determine programmatically is user is in role

百般思念 提交于 2019-11-29 09:36:08
What is the code for determining if a user is in a role? I have set up all the users through the ASP.NET Configuration Security tab but now want to put logic around some key areas so only people in certain roles can see and access these areas. if (User.IsInRole("rolename")) { // my action } Easy~ HttpContext.Current.User.IsInRole("roleName") Matthew Jones Check out the Roles class, specifically IsUserInRole, GetUsersInRole, AddUserToRole, etc. I use these all the time. thanks to "Chris Van Opstal". i solved my problem like this way, public ActionResult Index() { if (User.IsInRole("Supervisor")

Wordpress Role Display Name

陌路散爱 提交于 2019-11-29 07:21:23
I am looking for a neat way to get the Wordpress role display name. When you add the role (e.g. add_role( 'special', 'A Special Role'); ), you get to set a display name. When you get the role (e.g. get_role( 'special' ); ) the role object returned simply has the name and the capabilities object. WP_Role Object( [name] => special [capabilities] => Array() ) And no display name. The display name is used all over the WP Admin back-end (users.php and user-edit.php), but it's a rabbit warren ... and I haven't been able to find a function that will return it. You can readily see it in the wp_user

What is the best mechanism to implement granular security (i.e. authorization) in an ASP.NET MVC application?

会有一股神秘感。 提交于 2019-11-29 01:52:41
Suppose a high-speed developer was tasked with building a banking application which would be accessed by many different people. Each person would want to access his or her own account information but would not want others to access it. I would like to know the best practice for restricting access in an MVC application so that only the user who owns the information (or an administrator) could access it. The Authorize attribute allows us to restrict by role. While this is a starting point, it seems that any authenticated user could gain access to any other user's information. ActionFilters seem

How to create roles and add users to roles in ASP.NET MVC Web API

为君一笑 提交于 2019-11-28 20:31:01
问题 I have a .NET Web API project that users the individual accounts. I can register users fine using the standard template AccountController. However, I now want to set up roles and add users to roles depending on the type of user. There are no roles automatically set up in the DB. How do I set up the roles and how do I add users to the roles? The only information I can find on this is based on the old ASP.NET Membership, so it fails on the fact that the stored procedures are not set up for it.

When are user roles refreshed and how to force it?

ⅰ亾dé卋堺 提交于 2019-11-28 19:22:40
First off, I'm not using FOSUserBundle and I can't because I'm porting a legacy system which has its own Model layer (no Doctrine/Mongo/whatsoever here) and other very custom behavior. I'm trying to connect my legacy role system with Symfony's so I can use native symfony security in controllers and views. My first attempt was to load and return all of the user's roles in the getRoles() method from the Symfony\Component\Security\Core\User\UserInterface . At first, it looked like that worked. But after taking a deeper look, I noticed that these roles are only refreshed when the user logs in.

ASP.NET MVC - Dynamic Authorization

社会主义新天地 提交于 2019-11-28 18:54:04
I am building a simple CMS in which roles are set dynamically in the admin panel. The existing way of authorizing a controller method, adding [Authorize(Roles="admin")] for example, is therefore no longer sufficient. The role-action relationship must be stored in the database, so that end users can easily give/take permissions to/from others in the admin panel. How can I implement this? If you want to take control of the authorization process, you should subclass AuthorizeAttribute and override the AuthorizeCore method. Then simply decorate your controllers with your CmsAuthorizeAttribute

Angular2 routing canActivate and AuthGuard (JWT) with user role parameter

安稳与你 提交于 2019-11-28 16:59:12
In this exaple project with JWT authentication we se how to allow only authenticated users to some route: import { RouterConfig } from '@angular/router'; import { Home } from './home'; import { Login } from './login'; import { Signup } from './signup'; import { AuthGuard } from './common/auth.guard'; export const routes: RouterConfig = [ { path: '', component: Login }, { path: 'login', component: Login }, { path: 'signup', component: Signup }, { path: 'home', component: Home, canActivate: [AuthGuard] }, { path: '**', component: Login }, ]; I would like make step further and also indicate what

Group vs role (Any real difference?)

心已入冬 提交于 2019-11-28 15:01:51
Can anyone tell me, what's the real difference between group and role? I've been trying to figure this out for some time now and the more information I read, the more I get the sense that this is brought up just to confuse people and there is no real difference. Both can do the other's job. I've always used a group to manage users and their access rights. Recently, I've come across an administration software, where is a bunch of users. Each user can have assigned a module (whole system is split into a few parts called modules ie. Administration module, Survey module, Orders module, Customer

Best Practices for Roles vs. Claims in ASP.NET Identity

左心房为你撑大大i 提交于 2019-11-28 13:56:43
问题 I am completely new to the use of claims in ASP.NETIdentity and want to get an idea of best practices in the use of Roles and/or Claims . After all this reading, I still have questions like... Q: Do we no longer use Roles? Q: If so, why are Roles still offered? Q: Should we only use Claims? Q: Should we use Roles & Claims together? My initial thought is that we "should" use them together. I see Claims as sub-categories to the Roles they support. FOR EXAMPLE: Role: Accounting Claims :

Can we personalize Session Timeout for Roles in ASP.NET MVC 5

一世执手 提交于 2019-11-28 11:27:30
The idea is to set different values of Session Timeout for different User Roles in ASP.NET MVC 5 and ASP.NET Identity. Is it possible to do? Based on their role you could set the timeout, i.e. HttpContext.Current.Session.Timeout = 20; Going by your previous question you want to do this dynamically. You could store and update the times themselves in session and set for each role on OnActionExecuting of a base controller. if (User.IsInRole("Admin")) { filterContext.HttpContext.Session.Timeout = (int)filterContext.HttpContext.Session["AdminTimeoutThatYouSetSomewhereElseGlobally"]; } If you are