Contents
CSRF 토큰 비활성화
   Aug 12, 2022     2 min read

데이터들을 받는다. Security는 서버를 감싸고 있으며, 데이터들을 서버에 들어가기 전 검사를 한다.

그 검사 이름이 CSRF 토큰 검사를 한다.

Untitled 2

요청(회원가입페이지)을 보내고 서버에서 응답할 때 signup.jsp 파일에다가 CSRF 토큰을 심어서 클라이언트에게 돌려준다.

페이지를 받을 때 input tag에 임시의 난수 값이 생겨서 보내진다.

예시)CSRF 토큰이 달려서 돌아올 때 이런식으로 돌아온다. → csrf="난수"

<input type="text" name="username" placeholder="유저네임" required="required" csrf="난수"/>
  • 클라이언트가 CSRF 토큰을 넣어서 보낸다면 ?
<input type="text" name="username" placeholder="유저네임" required="required" csrf="난수" />
<input type="password" name="password" placeholder="패스워드" required="required" csrf="난수" />
<input type="email" name="email" placeholder="이메일" required="required" csrf="난수" />
<input type="text" name="name" placeholder="이름" required="required" csrf="난수" />

Untitled 3

Security가 CSRF 토큰이 있는지 확인한다

postman 같은 것으로 접근 사용자 인지? 홈페이지로 접근하는 사용자인지? 구분하기위해서 CSRF 토큰!

  • postman으로 접근 사용자인지 ? (불법적인 매크로 ? 사용자인지? )

똑같이 403 에러뜬다! CSRF가 막고있다.

Untitled 4

Untitled 5

CSRF 토큰 비활성화

  • *http*.csrf().disable(); 을 configure 안에 넣어준다. 그러면 CSRF 토큰은 비활성화 된다.
├─📁COME.COS.photogram
   
   ├─📁config
       
       │─ 📦 SecurityConfig.java
@Override
protected void configure(HttpSecurity http) throws Exception {
			*http*.csrf().disable();
}