Majid
Majid

Reputation: 664

Design pattern for permissions management

Here's my problem: I'm working on an application where the users have certain rights. Depending on these rights, they would have access to some functions.

My problem is that I would have to test for every case if the user has the rights or not and enable it or not. For a big app, this task is quite tiring. I want to ask if there is a design pattern or library that simplifies the management of this. My goal is to disable buttons when the user does not have proper permissions.

Upvotes: 0

Views: 1919

Answers (1)

Metalhead
Metalhead

Reputation: 1449

Multiple things needs to be considered for such a solution

In an idea scenario, I will have following way of dealing with this problem.

  1. I will have user belonging to USergroup and Roles assigned to each Usergroup in some database.

  2. When the user logins to the application, you can fetch the usergroup and associated user roles from the database.

  3. Using the roles , you can create a map to store functionaNames/field names which has access.
  4. Pass this map in the session scope and using its values, enable/disable fields & buttons.
  5. Best way is to have a custom tag implemented for fields & buttons to be used in the jsp and then passing the map object to such tags which will validate the map and accordingly show the field or hide it.

Just want to keep it short and simple.

Upvotes: 1

Related Questions