intercept-url的access属性可以持有什么值?

What values can be held by the access attribute of intercept-url?

In the spring-security example 我遇到了以下标签:

<intercept-url pattern="/admin**" access="hasRole('ROLE_ADMIN')" />

所以我想我们可以指定任何角色,指定的 url-pattern 可能是可访问的。我的问题是 hasRole('ROLE_NAME') 是唯一可以分配给 access 属性的模式。或者我们可以指定其他内容?

hasRole(ROLE_NAME) 是所谓的 基于表达式的访问控制,它是从 3.0[=32= 引入的] 发布 Spring 安全。

access 属性中定义的表达式允许计算复杂的布尔指令并将其与简单的配置属性一起使用。

除了 hasRole([role]) 之外,已经有许多内置表达式可供使用,例如:

  • hasAnyRole([role1,role2,...])
  • isAnonymous()
  • isAuthenticated()...

更多可以在el-access chapter of the Spring Security Docs下找到。