Spring Seurity 적용 후 잘 되던 회원가입 기능이 동작하지 않는 문제가 발생했다.
csrf 무시 설정을 적용하지 않아서였다.
해결법
- SecurityConfig 파일에 csrf 공격 방지 기능을 사용하고 싶지 않은 경로를 설정하기
http.
authorizeRequests()
....
.and()
.csrf().ignoringAntMatchers("/signup")
.and()
...
//아예 csrf 설정을 끌 수도 있다.
csrf().disable()
- jsp 파일의 폼 태그 마지막에 다음과 같이 추가한다
<form method="post" action="/signup">
...
<input type='hidden' name='${_csrf.parameterName }' value='${_csrf.token }'>
</from>
1번 방법의 경우 보안이 취약해지므로 지양해야한다.
'Java > Spring Boot' 카테고리의 다른 글
[SpringBoot] Could not find acceptable representation (0) | 2024.05.11 |
---|---|
[SpringBoot] 엔드포인트 권한 에러 (0) | 2024.05.11 |
[SpringBoot] 서버 시작 시 에러 (0) | 2024.05.11 |
[SpringBoot] Spring Seurity 정리 (0) | 2024.05.11 |
[SpringBoot] input 태그의 date 타입을 자바 Date 객체로 파싱하기 (0) | 2024.05.11 |