보안 적용 메소드requestMachers 와 antMachers사용예시FullyAuthenticated권한 체크 시 ROLE_USER에서 Prefix빼고 인가허용하는 방법hasRole vs hasAuthority
보안 적용 메소드

requestMachers 와 antMachers
- requestMatchers
public
C requestMatchers(
RequestMatcher
... requestMatchers)
- For all the incoming http requests, i want to filter them based on this list of matchers(RequestMacher)
- antMatchers의 메서드 시그니처
public
C antMatchers(HttpMethod method)
public
C antMatchers(HttpMethod method, String... antPatterns)
public
C antMatchers(String... antPatterns)
사용예시
- 위의 예시처럼 antMatchers는 먼저 선언된 것을 우선시 함
- .antMatchers(GET, "/departments").hasRole("USER") 를 선언하고 그 후에 hasRole(”ADMIN”)으로 선언하면 Role은 User 로 설정됨
FullyAuthenticated
isFullyAuthenticated(), which returns true if the user isn't an anonymous or remember-me user:
권한 체크 시 ROLE_USER에서 Prefix빼고 인가허용하는 방법
- 주석처리 되어 있는 부분 처럼 access를 활용하여 직접 SpEL 을 명시하여 GUEST를 가질 때로 작성하면, Prefix 빠지고 가능함
- 또는 hasAuthority(”GUEST”) 로도 가능함
hasRole vs hasAuthority
- hasRole은 role related method에서 ROLE_이라는 prefix를 붙여줌
- hasAuthority는 prefix가 하나도 안붙는다는 장점!