Skip to content

Commit 97fd3d7

Browse files
Kristine Jetzkeeleftherias
Kristine Jetzke
authored andcommitted
Clarify usage of hasAnyRole and hasAnyAuthority
1 parent 9f6a364 commit 97fd3d7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,32 @@ This provides some common expressions which are available in both web and method
2121
|===
2222
| Expression | Description
2323

24-
| `hasRole([role])`
24+
| `hasRole(String role)`
2525
| Returns `true` if the current principal has the specified role.
26+
27+
For example, `hasRole('admin')`
28+
2629
By default if the supplied role does not start with 'ROLE_' it will be added.
2730
This can be customized by modifying the `defaultRolePrefix` on `DefaultWebSecurityExpressionHandler`.
2831

29-
| `hasAnyRole([role1,role2])`
32+
| `hasAnyRole(String... roles)`
3033
| Returns `true` if the current principal has any of the supplied roles (given as a comma-separated list of strings).
34+
35+
For example, `hasAnyRole('admin', 'user')`
36+
3137
By default if the supplied role does not start with 'ROLE_' it will be added.
3238
This can be customized by modifying the `defaultRolePrefix` on `DefaultWebSecurityExpressionHandler`.
3339

34-
| `hasAuthority([authority])`
40+
| `hasAuthority(String authority)`
3541
| Returns `true` if the current principal has the specified authority.
3642

37-
| `hasAnyAuthority([authority1,authority2])`
43+
For example, `hasAuthority('read')`
44+
45+
| `hasAnyAuthority(String... authorities)`
3846
| Returns `true` if the current principal has any of the supplied authorities (given as a comma-separated list of strings)
3947

48+
For example, `hasAnyAuthority('read', 'write')`
49+
4050
| `principal`
4151
| Allows direct access to the principal object representing the current user
4252

0 commit comments

Comments
 (0)