5
在我工作的项目中,我们基于角色id而不是角色描述进行身份验证,并且此映射存储在数据库中。Spring Security删除RoleVoter前缀
我的问题是,如何删除了Spring Security的RoleVoter前缀来实现设计如上?
在我工作的项目中,我们基于角色id而不是角色描述进行身份验证,并且此映射存储在数据库中。Spring Security删除RoleVoter前缀
我的问题是,如何删除了Spring Security的RoleVoter前缀来实现设计如上?
弹簧安全RoleVoter
需要前缀以区分作为角色的授予权限,请参阅answer了解更多详细信息。
如果你想改变这种情况,可以随时为自己的自定义AccessDecisionManager and configure it with a custom
RoleVoter`。
这是这样一个自定义的访问决策管理的一个例子:
public class MyAccessDecisionManager extends AffirmativeBased {
public MyAccessDecisionManager() {
super();
List<AccessDecisionVoter> decisionVoters = new ArrayList<AccessDecisionVoter>();
RoleVoter roleVoter = new MyCustomRoleVoter();
decisionVoters.add(roleVoter);
AuthenticatedVoter authenticatedVoter = new AuthenticatedVoter();
decisionVoters.add(authenticatedVoter);
setDecisionVoters(decisionVoters);
}
以及在地方的默认访问决策管理器的使用它:
<bean id="myAccessDecisionManager" class="full.package.name.MyAccessDecisionManager" />
<security:http access-decision-manager-ref="myAccessDecisionManager">
...
</security:http>
如何配置它在'春天-security.xml'? – khateeb
我用XMLconfig更新了答案。 –
构造函数AffirmativeBased()在spring security 4.1.3中未定义 – Julien