SecurityConfig
@EnableWebSecurity
@Configuration
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception{
http
.csrf(csrf ->
csrf.disable())
.cors(cors ->
cors.disable())
.authorizeHttpRequests((auth) ->
auth
.requestMatchers(new AntPathRequestMatcher("/**")).permitAll()
);
return http.build();
}
}
나중에 필요할시 설정하기위해 임시로 csrf와 cors를 비활성화 해주고 모든 경로에 대한 요청을 허용했다
CSRF와 CORS가 무엇인지 간단하게 설명하면 (추후에 자세히 포스팅 예정)
CSRF란
Cross Site Request Forgery (사이트 간 요청 위조)의 약자로 웹 보안 취약점의 일종이다.
인증된 사용자가 특정 요청을 보내도록 유도하는 공격이다
XSS와 비슷하지만 차이점은 인증된 사용자와, 인증되지 않은 사용자 스크립트가 사용자에서 실행, 서버에서 실행
하는것에 차이점이 있다.
CORS란
Cross Origin Resouce Sharing (교차 출처 리소스 공유)의 약자로 다른 출처(Origin) 간의 리소스를 공유하는 법이다.
출처(Origin)이란 Protocol, Host, Port(생략가능)을 통틀어서 말한다.
이 셋중 하나라도 다르다면 Cross Orgin이 되는것이다.
https://localhost/example | https://localhost/about | 같은 출처 | Protocol, Host, Port 같음 |
https://locahost/example | https://localhost:82/example | 다른 출처 | Port 다름 |