Many questions have already been asked about Claims-based authentication and the differences with other approaches: Role-based vs Claims-based Explain claims-based authentication Now, my favorite answer is one given on stackoverflow: Using claims-based authentication.
However, after reading through them, my question is not solved. The question I have is twofold:
- Is there a difference between claims and attributes (ABAC)?
- If we may look at a 'role' as being a claim, what is the particular advantage of claims-based authorization over role-based authorization? (note: I'm using authorization instead of authentication here, as I feel it is not really about authentication).
To elaborate my question further, I will give three examples of how I see claims-based, role-based, and attribute-based authorization. Disclaimer: I am not sure if these examples are correct, they are just part of my question.
Claims-based example
I have read through an interesting blogpost in which it is explained how we could use claims-based authentication in MVC / Web API. It seems that (in that blogpost) a method is secured (authorized) by looking at the claims that are associated with the user who is trying to access the method. If that user has a claim to 'view' 'streetaddresses', then he is authorized to view that data.
[ClaimsAuthorize("Read", "SomeData")]
public string Get()
{
return “somedata”;
}
Now, the creation of the claims is separated somewhere else, which is not really specified in that blogpost. I'm assuming that hidden method checks whether that user, with that certain role, is allowed to view streetaddresses. Now then what is the difference with role-based authorization?
Role-based example
The difference is not clear to me, let's compare it with the old role-based authorization. I can once again define an attribute for each method, which restricts the execution of that method to certain roles. The 'view streetaddresses' method is for example restricted to users with the role 'admin'. So instead of checking the role in the separate method, we check it right here. Or am I missing something here?
[RoleAuthorize('admin')]
public string Get()
{
return “somedata”;
}
Attribute-based example
I do see the advantage of a more fine-granular authorization control. But I would implement something like this, to define that only a user with the role admin can access 'somedata' during working hours, and only if that admin user has blue eyes.:
[AttributeAuthorize('role=admin;time=09-17;eyecolor=blue')]
public string Get()
{
return “somedata”;
}
This last example really seems advantageous to me, but I'm not sure whether or not it is the same as my first example, which is claims-based authorization.
To end, a last question has popped up:
- This means that claims ARE different from attributes, as attributes are used to define which rights a user has, whereas claims are these rights?