Skip to content

Conversation

@StoneCAU
Copy link
Member

📌 Issue Number

🪐 작업 내용

  • 효율적으로 DB를 활용하기 위해 redis를 사용했습니다.
  • 액세스 토큰은 db에서, 리프레시 토큰은 redis에서 관리

✅ PR 상세 내용

  • 회원가입: 리프레시 토큰 redis 저장
  • 로그인: 기존 리프레시 토큰 redis 삭제, 새 액세스 토큰 db저장, 새 리프레시 토큰 redis 저장
  • 로그아웃: 리프레시 토큰 redis 삭제, 액세스 토큰 블랙리스트(redis)
  • 토큰 재발급: 기존 토큰 무효화(각각 redis 삭제, 블랙리스트 추가), 새로운 토큰 저장(각각 redis, db 저장)
  • 회원탈퇴: 기존 토큰 무효화

📸 스크린샷(선택)

image

Key 값을 통해 redis에 잘 저장되는거 확인

📚 Reference

https://eesko.tistory.com/353
https://onethejay.tistory.com/34

@StoneCAU StoneCAU added the feat label Feb 12, 2025
@StoneCAU StoneCAU self-assigned this Feb 12, 2025
Copy link
Collaborator

@westjiuuu westjiuuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

public boolean isRefreshTokenValid(String refreshToken, Long memberId) {
String key = REDIS_REFRESH_TOKEN_KEY_PREFIX + memberId;
String storedUserId = redisTemplate.opsForValue().get(key);
return !storedUserId.isBlank();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redis에서 해당 키가 없으면 null을 반환하니까 isBlank대신 null 체크로 검사하는게 좋을 거 같습니다!

@StoneCAU StoneCAU merged commit 31a88e3 into main Feb 14, 2025
2 checks passed
@StoneCAU StoneCAU deleted the feature/177 branch February 14, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] redis를 통한 리프레시 토큰 관리

3 participants