login

    [Django] DRF를 사용한 JWT Authentication #2

    이번 포스팅에서는 JWT를 생성하고 로그인,로그아웃 기능을 구현하는 방법을 정리해 보려고 한다. 로그인 로직 클라이언트는 LoginApi를 호출하면서 {"username": "이름", "password": "비번"} 정보를 전달해준다. 서버는 username과 password를 가지고, 해당하는 유저를 찾은 다음 jwt_login을 수행한다. jwt_login에서는 access_token과 refresh_token을 생성한다. 생성된 access_token은 {"access_token": access_token}형태의 json으로 클라이언트에 전달되고, 생성된 refresh_token은 httpOnly=True 속성을 가진채로 cookie에 삽입된다. 로그아웃 로직 클라이언트에서 LogoutApi를 호출..