在shiro.ini
中,我声明了以下SQL查询:
jdbcRealm.authenticationQuery = SELECT password FROM Person WHERE email = ?
jdbcRealm.userRolesQuery = SELECT id FROM SecurityRole WHERE id = (SELECT securityRole_id FROM Person WHERE email = ?)
jdbcRealm.permissionsQuery = SELECT action FROM SecurityPermission WHERE id = (SELECT permissions_id FROM securityrole_securitypermission WHERE securityrole_id = ?)
当我用?
替换上一个查询中的1
时,在db上运行它会返回预期结果:rest:*
但SecurityUtils.getSubject().isPermitted(new WildcardPermission("rest"));
会返回false
,但登录用户的ID为1的分配角色,securityrole_securitypermission
的条目为1和1,securitypermission
的ID为1有action
=“休息:*”。
答案 0 :(得分:3)
jdbcRealm.permissionsLookupEnabled = true
完成了这项工作。 ;)