何时使用自定义 AccessDecisionManager(需要真实的用例)
我只是好奇 当我需要使用自定义 AccessDecisionManager 时 我需要你们经验丰富的人提供一些用例,如果有人以前用过的话,谢谢。
i am just curious
when i will need to use a custom AccessDecisionManager
i need some use cases from your experience guys, if anyone have used it before, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Spring Security 文档用于自定义选民统计,例如某个特定选民的权重是否应该比其他选民更大。
您还可以根据传递给
decide
方法的安全对象的属性(例如,基于现有业务逻辑)来自定义行为。 (这也可以通过自定义投票器或其他方式来处理,但如果它是通用的,则将其放入决策管理器中可能会更容易。)IMO 在这个级别需要广泛的自定义是相对不寻常的,但其他人可能有更多的见解。
The canonical example given in the Spring Security docs is for customizing voter tallies, like if a particular voter should be weighted more heavily than others.
You could also customize behavior based on, say, properties of the secured object passed in to the
decide
method, for example, based on existing business logic. (That could also be handled by a custom voter, or other means, but if it's generic it might be easier to put it in a decision manager.)IMO it's relatively unusual to need extensive customization at this level, but others may have additional insight.
如果您有授予权限的复杂对象,您还需要一个自定义的 AccessDecisionManager,spring 默认仅支持字符串。
You also need a custom AcceessDecisionManager if you have complex object for a granted authority, spring default only supports string for that.