Here is the thing: I want to have users with roles like this:
Table users: id|username|role_id
Table roles: id|name|add_users|add_customers|configure_mail|...|...|...
The permissions are type binary, when the user can perform the action It has a 1 or It has a 0 otherwise.
In my shiro.ini I have the queries:
jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.authenticationQuery = SELECT password from users where username = ?
jdbcRealm.userRolesQuery = select name from roles where id = (select role_id FROM users WHERE username = ?)
Is there a way to do that?. I have searched for days now. I would really appreciate your help. Thanks in advance guys.
I got It!!. Thanks to dev, he really helped me to solve this, here is the solution (shiro.ini)
jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.permissionsLookupEnabled = true
jdbcRealm.authenticationQuery = SELECT password from users where username = ?
jdbcRealm.userRolesQuery = select id from roles where id = (select role_id FROM users WHERE username = ?)
jdbcRealm.permissionsQuery = SELECT name FROM permissions WHERE UPPER(role_id)=UPPER(?)
I hope It will help someone in the future and thanks for your help @dev