spring security 表达式

hasRole

判定是否有指定的角色,若指定的角色中没有以”ROLE_”开头,则会自动加上,如hasRole(“admin”) 则表示判断是否有”ROLE_admin”角色,而非判断是否有”admin”角色.”ROLE_”可以在DefaultWebSecurityExpressionHandler类中修改默认设置.

hasAnyRole

判断是否有指定角色中的任意一个.

hasAuthority

判断是否有指定的角色

hasAnyAuthority

判断是否有指定角色中的任意一个

principal

Allows direct access to the principal object representing the current user (没看懂是什么意思)

authentication

Allows direct access to the current Authentication object obtained from the SecurityContext (没看懂是什么意思)

permitAll

不管控,所有的人都可以访问

denyAll

禁止所有的人访问

isAnonymous

判断是否是匿名用户,即用户未登录则返回true

isRememberMe

从字面讲理解用户记住登录的则返回true(但是不太理解具体是什么意思)

isAuthenticated

用户已经登录的则返回true

isFullyAuthenticated

用户已经登录了,且不是RememberMe状态的.

hasPermission(Object target, Object permission)

检验是否有某对象的指定权限.

hasPermission(Object targetId,String targetType, Object permission)

检验是否有某对象的指定权限(不太明白怎么使用前两个参数来确定具体的对象).

猜你喜欢

转载自blog.csdn.net/shui878412/article/details/53353657