[ODOP] 93일차 - WebIgnore 설정 [js/css/image]
![[ODOP] 93일차 - WebIgnore 설정 [js/css/image]](/content/images/size/w1200/2023/08/-----2023-08-01----10.29.26-26.png)
- js, css, image 파일 등 보안 필터를 적용할 필요가 없는 리소스를 ignore 설정
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
public class SecurityConfig extends WebSecurityConfigurerAdapter {
...
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().requestMatchers(PathRequest.toStaticResources().atCommonLocations());
}
...
}
해당 PathRequest.toStaticResources().atCommonLocations() 를 확인 해 보면 아래와 같은 코드를 확인 할 수 있다.
![](https://blog.pollra.com/content/images/2023/08/-----2023-09-01----5.01.36.png)
해당 EnumSet.allOf
는 인자로 주어진 Enum 클래스의 요소를 모두 EnumSet(AbstractSet 의 구현체)
라는 Set
자료구조에 담아 리턴하고있다.
그렇다면 중요한 것은 저 StaticResourceLocation.class
로 보인다.
![](https://blog.pollra.com/content/images/2023/08/-----2023-09-01----5.02.11.png)
이렇게 기본적인 설정을 제공하는 것을 확인 할 수 있다.
만약 spring 에서 기본적으로 제공하는 경로가 아닌, 본인이 임의로 처리하는 경우 이 부분을 참고하여 처리하면 될 것 같아 보인다.