我使用grails 2.3.4和spring-security-core:2.0-RC4作为必备条件我需要拥有权限组和用户特定权限而无需添加组...
关于文档:
请注意,使用群组时,“#person”之间不应有联接类。和'权威',因为' group'居住在两者之间。
真的没有办法做到这一点吗?如果我有必要,我应该选择其他替代品而不是春季秒?也许手动做? shiro能解决我的问题吗?
编辑:useRoleGroups在配置中显然是使其仅按组获取权限的设置。
感谢任何帮助。
答案 0 :(得分:3)
我使用:
实现了GormUserDetailsService和修改的loadAuthorities方法 if (useGroups) {
if (authorityGroupPropertyName) {
authorities = userAuthorities.collect { it."$authorityGroupPropertyName" }.flatten().unique().collect { new SimpleGrantedAuthority(it."$authorityPropertyName") }
}
else {
log.warn "Attempted to use group authorities, but the authority name field for the group class has not been defined."
}
}
LinkedHashSet<Role> ua = UserRole.findAllByUsuario(user).collect { it.role }
if(!ua.empty) {
ua.flatten().unique().collect { new SimpleGrantedAuthority(it.authority) }.each { authorities.add(it) }
}