Skip to content

[Chore] Refresh Token Redis 연동 - #17

Merged
kosy00 merged 4 commits into
developfrom
feat/16-refresh-token-redis
Jun 23, 2026
Merged

[Chore] Refresh Token Redis 연동#17
kosy00 merged 4 commits into
developfrom
feat/16-refresh-token-redis

Conversation

@kosy00

@kosy00 kosy00 commented Jun 23, 2026

Copy link
Copy Markdown
Owner

관련 이슈

closes #16

구현 내용

  • RedisConfig: RedisTemplate Bean 등록 및 직렬화 설정
  • RefreshTokenRepository: Refresh Token Redis 저장/조회/삭제

주요 구현 포인트

RedisConfig

  • LettuceConnectionFactory로 Redis 연결
  • StringRedisSerializer로 key/value 모두 문자열 직렬화
    → Redis CLI에서 사람이 읽을 수 있는 형태로 저장

RefreshTokenRepository

  • key 패턴: "refresh:{userId}"
  • TTL 7일로 Refresh Token 만료 시간과 동일하게 설정
    → 만료된 토큰이 Redis에 쌓이지 않도록 자동 삭제
  • save / find / delete / exists 메서드 구성

참고

  • 실제 저장/검증/삭제 호출은 다음 브랜치(회원가입/로그인)에서 연결 예정
  • 브랜치명이 feat으로 되어 있는데 작업 자체는 chore임

체크리스트

  • 코드 구현 완료
  • 동작 확인
  • 불필요한 코드/주석 제거

Summary by CodeRabbit

릴리스 노트

  • 기반시설 개선
    • 리프레시 토큰을 안정적으로 저장/조회/삭제할 수 있는 세션 토큰 관리 기능을 추가했습니다.
    • 토큰 만료 시간 기반으로 자동 유효 기간을 적용해 세션 보안을 강화했습니다.
    • 토큰 존재 여부 확인을 통해 세션 처리의 신뢰성과 안정성을 개선했습니다.

@kosy00 kosy00 self-assigned this Jun 23, 2026
@kosy00 kosy00 added the chore 설정, 문서 등 label Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4590254c-7f49-4c06-8eef-1522a915e7be

📥 Commits

Reviewing files that changed from the base of the PR and between 4ba0c62 and 4660e6e.

📒 Files selected for processing (1)
  • src/main/java/com/ilson/spotwork/infra/redis/RefreshTokenRepository.java

📝 Walkthrough

Walkthrough

RedisConfig 클래스를 신규 추가하여 StringRedisSerializer가 적용된 RedisTemplate<String, String> 빈을 등록하고, RefreshTokenRepository를 신규 추가하여 refresh:{userId} 키로 리프레시 토큰을 7일 TTL과 함께 Redis에 저장·조회·삭제·존재 확인하는 기능을 구현한다.

Changes

Redis 리프레시 토큰 인프라

Layer / File(s) Summary
RedisTemplate 빈 등록 및 리프레시 토큰 레포지토리
src/main/java/com/ilson/spotwork/infra/redis/RedisConfig.java, src/main/java/com/ilson/spotwork/infra/redis/RefreshTokenRepository.java
RedisConfigStringRedisSerializer를 키·값 직렬화기로 설정한 RedisTemplate<String, String> 빈을 노출하고, RefreshTokenRepository가 해당 빈을 주입받아 refresh:{userId} 키에 7일 TTL로 토큰을 저장(save)·조회(find)·삭제(delete)·존재 확인(exists)하는 퍼시스턴스 동작을 제공한다.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 토끼가 Redis 창고를 열었어요,
키와 값에 문자열 옷을 입히고,
refresh:{userId} 라벨을 붙여
7일치 토큰을 냉장 보관했죠.
저장, 조회, 삭제, 존재 확인까지—
깡충깡충, 준비 완료! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 사항인 Refresh Token Redis 연동을 명확하게 설명하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿을 따르고 있으며, 관련 이슈, 구현 내용, 주요 포인트, 체크리스트를 모두 포함하고 있습니다.
Linked Issues check ✅ Passed PR이 이슈 #16의 RedisConfig 및 RefreshTokenRepository 구현 요구사항을 완전히 충족하며, 로그인 통합은 차후 PR로 예정되어 있습니다.
Out of Scope Changes check ✅ Passed 두 개의 신규 클래스(RedisConfig, RefreshTokenRepository)만 추가되었으며, 모두 이슈 #16의 범위 내에 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/16-refresh-token-redis

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/ilson/spotwork/infra/redis/RefreshTokenRepository.java`:
- Around line 27-29: The find() method in RefreshTokenRepository currently
returns a String that can be null, which risks causing NullPointerException when
callers don't perform null checks. Change the return type of the find(Long
userId) method from String to Optional<String> and update the implementation to
wrap the redis template result with Optional.ofNullable() instead of directly
returning the value, making null handling explicit and safer for callers.
- Line 15: The REFRESH_TOKEN_TTL constant in RefreshTokenRepository is hardcoded
to 7 days, but the JwtProvider class uses a configurable refreshTokenExpiration
value injected from application properties. If the configuration specifies a
different expiration time, the Redis TTL and JWT validation time will be
misaligned. Replace the hardcoded REFRESH_TOKEN_TTL with a field annotated with
`@Value` that reads the same configuration property used by JwtProvider (likely
jwt.refresh-token-expiration), ensuring both the Redis storage TTL and JWT token
validation use the same expiration duration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2729ef5c-662c-4bdb-9b51-7736c324dcb4

📥 Commits

Reviewing files that changed from the base of the PR and between fa7d5c1 and 4ba0c62.

📒 Files selected for processing (2)
  • src/main/java/com/ilson/spotwork/infra/redis/RedisConfig.java
  • src/main/java/com/ilson/spotwork/infra/redis/RefreshTokenRepository.java

Comment thread src/main/java/com/ilson/spotwork/infra/redis/RefreshTokenRepository.java Outdated
Comment thread src/main/java/com/ilson/spotwork/infra/redis/RefreshTokenRepository.java Outdated
@kosy00
kosy00 merged commit 069111c into develop Jun 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore 설정, 문서 등

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Refresh Token Redis 연동

1 participant