【发布时间】:2015-09-09 12:08:15
【问题描述】:
我是 Spring Security 的新手。在分析以下代码更改时,我无法理解为什么使用“#post”而不是“post”?为什么“post”这个词要以“#”为前缀? post 是一个对象。
@PreAuthorize("hasPermission(#post, 'MANAGER') or hasRole('ROLE_MODERATOR')")
+ @PreAuthorize("hasPermission(#post, 'write') or hasRole('ROLE_MODERATOR')")
public void updateFullyPost(Post post) throws AppException;
我参考了 spring 安全文档并找到了以下内容。
hasPermission(对象目标,对象权限) 如果用户有权访问所提供的目标以获得给定的权限,则返回 true。例如,hasPermission(domainObject, 'read')
第一个参数应该是一个目标对象。
有人可以提供一些指导吗?欣赏它。谢谢。
【问题讨论】:
标签: java spring security spring-security spring-security-oauth2