Security추가 후 Post 요청

보안 설정 후 잘 작동하는 PostMapping 컨트롤이 작동하지 않았습니다.

CSRF()는 게시물 요청을 차단합니다.

        http.csrf().disable();

SecurityConfig.java의 SecurityFilterChain에서 상속된 메서드에서코드를 추가하면 해결되었습니다.

@Configuration // 설정값으로 사용
public class SecurityConfig {

    @Bean // SecurityAdapter상속 대신 사용 /최신  // 시큐리티 기본 로그인화면 탈출하기위함
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        return http
                .csrf().disable() // CSRF() 로인해서 post 요청이 막히는것을 해제해줌 / post 403에러 해결
                .authorizeHttpRequests(auth -> auth //auth를 받아서 어떤 리퀘스트를 열것인지
                        .antMatchers(HttpMethod.POST, "/articles").permitAll() //Role메서드 추가예정
                        .anyRequest().permitAll()) //auth를 받아서 어떤리퀘스트든 다열겠다
                .formLogin().and() //폼로그인 사용
                .build();
    }

콘텐츠 초기 작성을 위한 보안 설정 관련 방법