You can pass the roles without using [Authorize(Roles = "Role name")]

Asked

Viewed 981 times

3

My system has dynamic roles("groups"), the user adding and putting users in.

Also arrow that if it can insert, edit, delete, etc...

With the use of Asp.net Identity Roles, he can do this dynamically, without the use of "Role = ", that is, without spending it fixed in the controller?

Is there any way? or will I have to do this part of roles from scratch the way I need to...

1 answer

1


Basically, the idea would be to write your own authorization attribute. It can be done on ASP.NET Identity or on ASP.NET Membership.

There is an answer where I talk about more alternative forms of authorization, as the implementation of permissions by activities. Basically, reimplementing permissions using ASP.NET Identity gives more work because it is various methods within the interface that need to be written. On the other hand, the possibilities are greater. Membership, although simpler, is a little more limited.

In this answer teaching to implement a simple authorization attribute for ASP.NET Membership.

  • Hey @Cigano, the first option with ASP.NET Identity tb needs to pass fixed value, if you do not have any example?

  • @Rod You have several examples. See here: http://answall.com/search?q=user%3A2999+Authorize

  • The examples are all with custom, unlike option 1 you quoted in the reply

  • At the time, I meant that you could use Claims instead of Roles, but I expressed myself very badly. I changed the answer to be more objective.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.