Search code examples
javashiro

which is better assign multiple permissions or multiple roles to user in shiro?


I am have web app there are 4 roles and there respective default-page

1.admin // have access to all page
2.developer // have access to personal page
3.editor // have access to personal page
4.deo // have access to personal page

when user login as admin he can add new users as well as update existing user details. when adding new users i want to give multiple roles to users and select there default page (so that when user login he is redirected to default page which is given by admin)

here my database tables

table users
username | password | defaultpage

table user_roles
username | role_name

table role_permissions
role_name | role_perm

how to do it by giving multiple roles or multiple permissions to user?


Solution

  • Whichever suits your requirement. If you have a role that matches exactly the permissions you want to grant, and you think you might update those without wanting to update all the users directly, use the role. It's just a data normalization in the end.