-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: 토큰 재발급 로직 중앙화 및 유지보수성 개선 #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @HI-JIN2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 Pull Request는 토큰 재발급 로직의 중복과 파편화를 해결하고 유지보수성을 개선하기 위한 대규모 리팩토링을 포함합니다. 기존에 여러 곳에 흩어져 있던 토큰 재발급 및 저장 책임을 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
토큰 재발급 로직을 중앙화하고 유지보수성을 개선하기 위한 리팩토링이 인상적입니다. ReissueAndStoreTokenUseCase를 도입하여 책임을 명확히 분리하고, TokenAuthenticator 내에서 Mutex를 사용한 동시성 제어 로직을 추가하여 안정성을 크게 향상시킨 점이 돋보입니다. 또한 TokenStateManager를 제거하고 TokenEventBus를 개선하여 전반적인 코드베이스를 단순화하고 견고하게 만든 점도 훌륭합니다. 전반적으로 매우 완성도 높은 리팩토링이라고 생각합니다. 한 가지 엣지 케이스에 대한 개선 제안을 리뷰 코멘트로 남겼으니 확인 부탁드립니다.
| val newRefreshToken = result.data.refreshToken | ||
|
|
||
| if (newAccessToken.isBlank() || newRefreshToken.isBlank()) { | ||
| ReissueAndStoreResult.TransientFailure(message = "reissue returned blank tokens") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
토큰 재발급 API가 성공(HTTP 200)했지만 응답으로 받은 토큰이 비어있는 경우, 현재 TransientFailure로 처리하고 있습니다. 이 경우 원본 API 요청은 실패하지만 사용자는 로그아웃되지 않습니다. 만약 이것이 일시적인 서버 문제가 아니라 지속적인 문제일 경우, 사용자는 앱의 모든 기능이 실패하는 상태에 머무르게 되어 좋지 않은 사용자 경험을 줄 수 있습니다.
이 엣지 케이스를 복구 불가능한 오류로 간주하여 ReissueAndStoreResult.RefreshInvalid를 반환하도록 변경하는 것이 더 견고한 방법일 것 같습니다. 이렇게 하면 TokenAuthenticator에서 로그아웃 로직이 실행되어 사용자가 다시 로그인할 수 있게 됩니다.
| ReissueAndStoreResult.TransientFailure(message = "reissue returned blank tokens") | |
| ReissueAndStoreResult.RefreshInvalid( | |
| responseCode = -1, // HTTP 에러 코드가 아닌 내부 로직 상의 문제임을 표시 | |
| message = "reissue returned blank tokens" | |
| ) |
Summary
위 문제를 해결하고,
토큰 만료 시 재발급 로직이 중복되고 파편화되어 유지보수가 어려운 문제를 해결합니다.
Describe your changes
ReissueAndStoreTokenUseCase로 재발급+저장 로직 중앙화TokenStateManager제거,TokenEventBus기반 이벤트 처리로 단순화OauthRepository.reissueToken반환 타입을ApiResult<Token>으로 변경 (실패 원인 보존)Issue
To reviewers
재발급 API (
oauths/reissue/token)기타
checkValidToken엔드포인트 필요성 확인테스트 필요