In this post we are going to discuss about creating RBAC applications . Before that , we will have a brief overview of RBAC.
What does R B A C mean .
R-Role
B-Based
A-Access
C- Control
So summing up , its all about implementing role based access control system in application . Now , we will see how to implement
this system and make use of it in our application . As , we all are familiar with Membership , Role , Profile Providers being available
in .Net 2.0 . Those role providers does provide the same functionality , but there are requirements some time to get more of them
so we will achieve those targets by using RBAC .
Say for Example , we are having roles being implemented in our application , like (admin , Hr , Senior HR , Trainee HR etc) ,
now in our application , we do want to implement such a functionality , where a role defined can perform certain access like
Senior HR can edit , update or delete the records while Junior HR can only ADD records and view records . Even going more deep , lets assume a scenario where on a certain form /view we want that a user with specific permission (access rights ) can only view a specific part of form while others cannot , that is a form is being displayed in a different-different way depending on the access rights of the user . So how to attain this .
We will attain this using RBAC Implementation .
For this , first of all we are going to create / define roles .
a. Super Admin
b. Admin
C. Manager
d .Operator
Now as , we do have a predefined set of roles who will be using our application . the next step is to identify objects of our application ex :
a. Invoice Master
b. Product Master
c. Customer Master
and so on …..
Now once object are being identified , the next step is to identify unique actions ( activities) which can be performed on all the objects ex:
a. Add
b. update
c. Delete
d. Moderate
e. Publish
and so on ……
The next step is to link these actions to the objects , that is making applicable pairs of objects and activities ex:
A. product master
- Add
- Update
B. Invoice Master
- Add
- Update
- Publish
and so on….
Here after next step is to define Permissions which is the most important step here , that is assigning the object –activity pair to roles ex:
A. Super Admin
All object – Activity Pair
B. Operator
- View Product
- Add Invoice
and so on ….
Save these role –object –activity pairs in a database table .
Now , Assign the roles to each user , ex;
John Smith
- Manager
Tim Uzzanti
- Operator
Jacob Sebastian
- Super Admin
and so on ….
So till this step , we do have a clear definition of user , his role and his role permissions . and most important the Object of Application
Now , when you authenticate the user , load its role – object –activity pair data into session, hash table , static object (depending on whatever frontend you use , web , desktop , mobile etc and what ever the best method to load this information as per the performance of your application ).
Here After you are ready to apply RBAC .
Now whenever an object of your application instantiates , just before that give a lookup to the role – object –activity pair corresponding to the object and fetch the permissions and apply them . ex:
The user logged in does not have Add Permission on Invoice Object , disable the Add Button .
btnAdd.Visible=User.HasPermission(Invoice.Add) ;
And it is done , RBAC is implemented .
I will be soon , posting the running code for this implementation using Asp.net , Sql server 2005 and c# . Keep watching this post .
For any specific queries /suggestions ping me up and i will respond to them.
VN:F [1.6.3_896]
Rating: 5.0/5 (1 vote cast)