Java_Spring Security

Minki CHO·2023년 1월 18일
0

CodeStates

목록 보기
21/43

접근 제어 표현식

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')
principal1)현재 사용자를 나타내는 principal 객체에 직접 접근할 수 있음
authentication1)SecurityContext로 조회할 수 있는 현재 Authentication 객체에 직접 접근할 수 있음
permitAll1)항상 true로 평가
denyAll1)항상 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')
profile
Developer

0개의 댓글