feat : Refresh Token을 이용한 Access Token 재발급 기능 구현#17
Merged
DongHyeonka merged 1 commit intoSynapsesa:developfrom Jun 19, 2025
Merged
Conversation
Access Token 만료 시 사용자의 인증을 원활하게 갱신하기 위해 Refresh Token 기반의 재발급 기능을 구현했습니다.
주요 변경사항:
- **RefreshToken 관리**: `RefreshToken` 엔티티와 `RefreshTokenRepository`를 추가하여 Refresh Token을 데이터베이스에 영속화합니다.
- **서비스 로직 구현**:
- `TokenManagementService`: Refresh Token의 유효성을 검증하고, 새로운 Access Token과 Refresh Token을 발급하는 핵심 로직을 담당합니다.
- `LoginSuccessHandler`를 수정하여, 로그인 성공 시 생성된 Refresh Token을 DB에 저장하거나 갱신하도록 했습니다.
- **API 엔드포인트 추가**:
- `TokenReissueController`: `POST /api/accounts/token/reissue` 엔드포인트를 통해 토큰 재발급 요청을 처리합니다. Refresh Token은 HttpOnly 쿠키에서 읽어옵니다.
- **응답 처리 및 리팩토링**:
- `AuthResponseWriter`: 토큰 관련 HTTP 응답(JSON 본문, HttpOnly 쿠키) 생성을 전담하는 유틸리티 클래스를 구현하여 코드 중복을 줄이고 역할을 분리했습니다.
- **통합 테스트**: `TokenReissueIntegrationTest`를 작성하여 재발급 성공, 쿠키 누락, 유효하지 않은 토큰 등 다양한 시나리오를 검증합니다.
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.
📌 관련 이슈
✨ PR 작업 내용
RefreshToken엔티티: Refresh Token을 DB에 저장하여 상태를 관리합니다.TokenManagementService: 토큰 유효성 검증, 재발급, DB 업데이트 등 핵심 비즈니스 로직을 처리합니다.TokenReissueController:/api/accounts/token/reissueAPI 엔드포인트를 제공합니다.AuthResponseWriter: 인증 관련 HTTP 응답 생성을 표준화하고 재사용성을 높였습니다.이미지 첨부
다음 할 일