浏览代码

Clarify usage of hasAnyRole and hasAnyAuthority

Kristine Jetzke 5 年之前
父节点
当前提交
97fd3d7c84
共有 1 个文件被更改,包括 14 次插入4 次删除
  1. 14 4
      docs/manual/src/docs/asciidoc/_includes/servlet/authorization/expression-based.adoc

+ 14 - 4
docs/manual/src/docs/asciidoc/_includes/servlet/authorization/expression-based.adoc

@@ -21,22 +21,32 @@ This provides some common expressions which are available in both web and method
 |===
 |===
 | Expression | Description
 | Expression | Description
 
 
-| `hasRole([role])`
+| `hasRole(String role)`
 | Returns `true` if the current principal has the specified role.
 | Returns `true` if the current principal has the specified role.
+
+For example, `hasRole('admin')`
+
 By default if the supplied role does not start with 'ROLE_' it will be added.
 By default if the supplied role does not start with 'ROLE_' it will be added.
 This can be customized by modifying the `defaultRolePrefix` on `DefaultWebSecurityExpressionHandler`.
 This can be customized by modifying the `defaultRolePrefix` on `DefaultWebSecurityExpressionHandler`.
 
 
-| `hasAnyRole([role1,role2])`
+| `hasAnyRole(String... roles)`
 | Returns `true` if the current principal has any of the supplied roles (given as a comma-separated list of strings).
 | Returns `true` if the current principal has any of the supplied roles (given as a comma-separated list of strings).
+
+For example, `hasAnyRole('admin', 'user')`
+
 By default if the supplied role does not start with 'ROLE_' it will be added.
 By default if the supplied role does not start with 'ROLE_' it will be added.
 This can be customized by modifying the `defaultRolePrefix` on `DefaultWebSecurityExpressionHandler`.
 This can be customized by modifying the `defaultRolePrefix` on `DefaultWebSecurityExpressionHandler`.
 
 
-| `hasAuthority([authority])`
+| `hasAuthority(String authority)`
 | Returns `true` if the current principal has the specified authority.
 | Returns `true` if the current principal has the specified authority.
 
 
-| `hasAnyAuthority([authority1,authority2])`
+For example, `hasAuthority('read')`
+
+| `hasAnyAuthority(String... authorities)`
 | Returns `true` if the current principal has any of the supplied authorities (given as a comma-separated list of strings)
 | Returns `true` if the current principal has any of the supplied authorities (given as a comma-separated list of strings)
 
 
+For example, `hasAnyAuthority('read', 'write')`
+
 | `principal`
 | `principal`
 | Allows direct access to the principal object representing the current user
 | Allows direct access to the principal object representing the current user