개발/Spring
[Spring Security] @Secured(ROLE_?)
설이주인
2023. 1. 13. 13:58
본래 필터 단에서 requestMatcher(" ? ").hasRole(" ? ")로 작업을 진행했다.
URL 하나하나 작업하는 부분이 생각보다 많은 시간을 요구하여
Spring Security에서 지원하는 @Secured로 작업 방향을 변경하기로 했다.
기존 SecurityConfig에서
조금 더 간소하게 바꾸고
@EnableMethodSecurity(securedEnabled = true, prePostEnabled = true)
어노테이션을 추가했다.
https://docs.spring.io/spring-security/reference/servlet/authorization/method-security.html
Method Security :: Spring Security
Sometimes, you may need to perform operations that are more complicated than are possible with the @EnableGlobalMethodSecurity annotation. For these instances, you can extend the GlobalMethodSecurityConfiguration, ensuring that the @EnableGlobalMethodSecur
docs.spring.io
TEST