Claims
based security is based on the concept that the identity of a person can be
represented by a set of claims about that person. A claim is a bit of
information that describes the person in a way that is digitally useful. Claims
typically contain the usual user name, or email, but they can include much
more. Information such as roles, phone numbers, zip codes, addresses, anything
that is typically used by applications to customize the user experience.
Claims-based
identity provides a standard way of acquiring identity information by
heterogeneous applications to validate service requests within and outside an
organization and also over the Web.
Abstracting Identity with Claims:
Authentication
and authorization are two of the most common aspects of the application
security. In Windows, security is generally handled using the Kerberos or the
NTLM security tokens.
This
works well within the boundaries of the Windows ecosystem; however, it gets
difficult if the application has to support the users that do not have Windows
Active Directory credentials. In the real world, the applications spanning
multiple platforms interact with each other and require the security context to
be shared. Using a claims-based identity model provides a robust way of
handling authentication and authorization across the discrete systems.
Claims Base Authentication:
Claims-Based
architecture allows you to delegate authentication logic into another entity.
This entity is a “some” layer which abstracts all authentication related coding
and gives your application what it needs: is the user authenticated or not, and
some information about the user (called claims or assertions) that lets your
application take authorization decisions.
How to
do it…
Following
example demonstrate how you can create a collection of claims from a
WindowsIdentity object,
1. Create a new Visual C# Console Application project in
Visual Studio
2.
Add a reference to System.IdentityModel assembly
3.
Open the Program.cs file, and include the System.IdentityModel.Claims and the System.Security.Principal namespaces.
4.
In the Main method, create a new instance of the WindowsClaimSet class, and pass the current context
identity as a parameter to the constructor. And then Loop through the ClaimSet object and print the claim information
into the console output

5.
Compile and run the
project. The result is displayed in the console window:

How it works…
The WindowsClaimSet
class inherits from the System.IdentityModel.Claims.ClaimSet. ClaimSet represents
a collection of claims (System.IdentityModel.Claims.Claim) associated with an entity. The WindowsClaimSet constructor accepts the current Windows user identity as a parameter and
returns a ClaimSet object containing the collection of claims that represent
the Windows Active Directory groups of the user. The current Windows user
identity is fetched using the WindowsIdentity.GetCurrent
method. Generated ClaimSet can be used to create a signed
security token that can be passed on to a service to create a security context
and implement role-based access control.
A claim is used to identify a user or provide access to a
particular resource requested by the user. There are three properties exposed
by the Claim
class:
ClaimType: It identifies the type of claim. In our example, Sid (security identifier)
and Name are the two claim
types displayed in the console window.
Resource: It identifies the
resource associated with the claim.
Right: It is a URI representing the Identity or PossessProperty right associated with the claim. PossessProperty determines whether the user has the access to Resource.
Both
the Claim and the ClaimSet classes are serialization-friendly, which allows them to be
transmitted over service boundaries.

No comments:
Post a Comment