반응형
이론상으로는 클라이언트에게 refreshToken이라는 값을 받아서 String으로 뽑아내는 코드다.
우리는 이러한 API를 테스트하기 위해 POSTMAN이라는 것을 사용한다.
https://www.postman.com/
Postman API Platform | Sign Up for Free
Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
www.postman.com
먼저 POST MAN을 설치한다.
Postman을 설치하고 설정 하는 과정은 생략하겠다.
https://chrome.google.com/webstore/detail/postman-interceptor/aicmkgpgakddgnaphhhpliifpcfhicfo
Postman Interceptor
Sends requests fired through the Postman chrome app.
chrome.google.com
그리고 Postman 쿠키를 사용할 수 있게 Postman Interceptor 플러그인을 설치한다.
설치한 후, send 밑에 있는 Cookies를 누른다.
Cookies를 누르면 나오는 창이다.
여기서 CONNECTED가 될 수 있게 다운로드하라는 글이 나오면 다운로드를 한다.
다운로드를 한 뒤, Add Domain을 눌러서 도메인을 추가해 준다.
이렇게 자신이 테스트할 도메인을 추가해 준다.
이런 화면이 나오면 성공한 것이다.
그런 다음에 밑의 코드처럼 쿠키를 만들어서 Response로 보내주는 코드를 실행시켜 보겠습니다.
밑의 줄에 있는 Cookie를 눌러서 쿠키를 확인해 보겠습니다.
이렇게 쿠키가 없었는데 Login을 실행시키면
위의 코드처럼 ResponseToken 쿠키가 생성이 됩니다.
이때 X 표시를 누르면 쿠키가 삭제가 됩니다.
이렇게 쿠키가 생성이 되면 쿠키를 필요로 하는 HTTP Method를 실행시켰을 때 문제없이 돌아갑니다.
잘 작동하는 모습을 볼 수 있습니다.
전체 코드는 밑의 링크에 있습니다.
https://github.com/yongjun-hong/Jwt_springSecurity
GitHub - yongjun-hong/Jwt_springSecurity: Stateless Restful API, SpringbootSecurity, JWT
Stateless Restful API, SpringbootSecurity, JWT. Contribute to yongjun-hong/Jwt_springSecurity development by creating an account on GitHub.
github.com
반응형