refact: 로그인시 자동로그인 체크 유무에 따른 rt 만료시간 설정 및 CSRF 설정#22
Merged
Conversation
jung-min-ju
approved these changes
Apr 12, 2025
Contributor
|
확인했습니다. |
jung-min-ju
approved these changes
Apr 14, 2025
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.
로그인시 자동로그인 체크 유무에 따른 rt 만료시간 설정 및 CSRF 설정
📝 개요
로그인시 자동로그인 체크 유무에 따른 rt 만료시간 설정 및 CSRF 설정
⚙️ 구현 내용
자동 로그인 여부에 따라 Refresh Token 쿠키의 만료 시간을 다르게 설정하였습니다.
자동 로그인을 체크하지 않은 경우에는 쿠키에 만료 시간을 설정하지 않아 브라우저가 종료되면 쿠키도 함께 삭제되어 로그인이 해제되며,
자동 로그인을 체크한 경우에는 쿠키에 만료 시간을 설정하여 브라우저가 종료되어도 만료 기간 내에는 로그인이 유지되도록 하였습니다.
또한, 토큰 재발급 시에도 최초 로그인 시의 자동 로그인 여부를 기준으로 동일한 방식으로 쿠키 만료 시간을 설정하여 일관된 동작을 보장합니다.
토큰 재발급 과정에서 발생할 수 있는 CSRF 공격을 방지하기 위해 CSRF 보호 기능을 도입하였습니다.
또한, CSRF 토큰 불일치로 인한 인증 실패 시 이를 처리할 수 있도록 예외 처리 로직을 추가하였습니다.
프로필을 추가하여 개발 상황에서 쿠키의 secure 설정을 false로 설정하여 Http 환경에서도 쿠키 발급이 가능하도록 하였습니다.
🧪 테스트 결과
자동로그인 비체크 시

자동로그인 체크 시

CSRF 토큰 불일치
