Spring Security에서 지원하는 표현식
표현식 | 설명 |
---|---|
hasRole(String role) | 1)현재 보안 주체(principal)가 지정된 역할을 갖고 있는지 여부를 확인하고 가지고 있을 때 true 리턴 2)hasRole('admin')처럼 파라미터로 넘긴 role이 "ROLE_"로 시작하지 않으면 기본적으로 추가함 (DefaultWebSecurityExpressionHandler의 DefaultRolePrefix를 수정하면 커스텀 가능) |
hasAnyRole(Sring... roles) | 1)현재 보안 주체가 지정한 역할 중 1개라도 가지고 있으면 true 리턴 (문자열 리스트를 콤마로 구분해서 전달) ex. hasAnyRole('admin','user') |
hasAuthority(String authority) | 1)현재 보안 주체가 지정한 권한을 가지고 있는지 여부를 확인하고 가지고 있다면 true 리턴 ex. hasAuthority('read') |
hasAnyAuthority(String... authorities) | 현재 보안 주체가 지정한 권한 중 하나라도 있으면 true 리턴 ex. hasAnyAuthority('read','write') |
principal | 1)현재 사용자를 나타내는 principal 객체에 직접 접근할 수 있음 |
authentication | 1)SecurityContext로 조회할 수 있는 현재 Authentication 객체에 직접 접근할 수 있음 |
permitAll | 1)항상 true로 평가 |
denyAll | 1)항상 false로 평가 |
isAnonymous() | 1)현재 보안 주체가 익명 사용자면 true 리턴 |
isRememberMe() | 1)현재 보안 주체가 remember-me 사용자면 true 리턴 |
isAuthenticated() | 1)사용자가 익명이 아닌 경우 true 리턴 |
isFullyAuthenticated() | 1)사용자가 익명 사용자나 remember-me 사용자가 아니면 true 리턴 |
hasPermission(Object target, Object permission) | 1)사용자가 target에 해당 permission 권한이 있으면 true 리턴 ex. hasPermission(domainObject, 'read') |
hasPermission(Object targetId, String targetType, Object permission) | 1)사용자가 target에 해당 permission 권한이 있으면 true 리턴 ex. hasPermission(1,'com.example.domain.Message','read') |