<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
package com.example.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
// 기존기능을 제거한 후 필요한 것을 추가
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
// super가 부모의 기능이다.
// 이걸 뺴버리면 부모기능을 안쓰겠다.
// h2 console db사용을 위해서 임시로
// 나중에 빼야함. 보안을 위해
http.csrf().disable();
http.headers().frameOptions().sameOrigin();
}
// extends가 안되는 상황에서 securityconfig에 컨트롤 .을 써서 불렀음
}
1. http.csrf().disable();
2. http.headers().frameOptions().sameOrigin();
1번을 안할시
2번을 안할시