Conversation
close [BE/FEAT] 카카오톡 로그인 구현 #2
Contributor
|
|
jeongpine14
reviewed
Jan 27, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
카카오톡 로그인 기능
구현 예정 기능
TODO
1. DB에 refresh token 저장 메서드 구현2. 로그아웃 시 DB에서 refresh token 삭제3. 토큰 재발급 메서드 구현
카카오 로그인 인증 과정 참고
API
카카오 로그인 과정
1.
http://localhost:3030/api/v1/auth/kakao접속2. 아래와 같이 카카오 로그인 페이지로 이동
3. 카카오 로그인 후,
http://localhost:3030/api/v1/auth/kakao/Callback으로 리다이렉트JWT 디코딩
미들웨어
Access Token 검증
Access Token 검증 성공
Access Token 검증 실패
소셜 로그인 기능 참고
JWT 저장 위치
고민
httpOnly,secure,sameSite)을 이용하여 안정성 확보Client
private변수)에 저장httpOnlysecuresameSite=LaxStrict모드Lax모드form을 통한GET요청 시에만 쿠키 사용 가능Local StorageDB에 저장된 Refresh Token의 index 값과user_id를 조합하여 Hashing한 값을 저장Server
JWT 핸들링 과정
1. Server
access token과refresh token생성refresh token을 DB에 저장access token은 JSON 객체로 응답refresh token을 쿠키에 담아httpOnly,secure,sameSite=Lax옵션을 지정하여 응답2. Client
access token은 메모리(private변수)에 저장AuthorizationHeader에access token을 담아 요청access token만료 혹은 페이지 이동으로 인해 토큰이 사라졌을 경우, Server로access token재발급 요청access token재발급 요청 시, 쿠키에refresh token값을 담은 상태로 Server와 통신3. Server
access token재발급 요청을 받을 경우, Client로부터 받은refresh token을 확인 후access token과refresh token을 재생성한다.etc
1. 로그 파일 수정 (좀 더 손봐야 함)
[object Object]와 같이 포맷팅 된 채로 출력돼서logger.js를 수정하였습니다.close [BE/FEAT] 카카오톡 로그인 구현 #2