I am trying to secure asp.net web-api 2.0 with Windows Identity Foundation 2. The choice I have to make is between role based authorization and claims based authorization. As a practice, I added a users in DbInitializer
and assigned him two roles (Admin and Manager). When I log in with that user, I see that ClaimsPrincipal
in debug mode, it already has those roles (Admin and Manager) associated as claims. So here are the questions:
If roles are also treated as claims, what is the difference b/w roles and claims then?
If I keep away from roles, how can I use claims to protect web api controllers and associated action methods. Like, I have an orders controller containing CRUD methods. I want one user (say a manager) to have access to Create and Get method and the second user (an admin) to have access to all those methods.
How would I do that? with role based system, I would simply decorate the action methods with appropriate
Authorize(Role = "Admin")
attribute. How would I manage the claims itself? do I need to add them in database and grant/revoke those claims to different users through my application?