Skip to content

Conversation

@HI-JIN2
Copy link
Member

@HI-JIN2 HI-JIN2 commented Jan 26, 2026

Summary

현재 엑세스 토큰 1일 / 리프레시 토큰 7일인데, 배포 버전에서 하루마다 로그아웃되는 일이 발생하고 있습니다

위 문제를 해결하고,
토큰 만료 시 재발급 로직이 중복되고 파편화되어 유지보수가 어려운 문제를 해결합니다.

Describe your changes

  • ReissueAndStoreTokenUseCase로 재발급+저장 로직 중앙화
  • TokenStateManager 제거, TokenEventBus 기반 이벤트 처리로 단순화
  • OauthRepository.reissueToken 반환 타입을 ApiResult<Token>으로 변경 (실패 원인 보존)

Issue

To reviewers

재발급 API (oauths/reissue/token)

  • Refresh 만료/무효 시 HTTP 상태 코드 확인 (현재: 401/403 가정)
  • 일시적 실패 시 응답 코드 구성 확인
  • 리다이렉트(3xx) 사용 여부 확인

기타

  • checkValidToken 엔드포인트 필요성 확인
  • 동시 재발급 요청 시 서버 처리 정책 확인

테스트 필요

  • 동시 요청 시 뮤텍스 동작
  • Refresh 만료 시 로그아웃 처리
  • 네트워크 실패 시 재시도 로직
  • 백그라운드 토큰 만료 이벤트 처리

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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는 토큰 재발급 로직의 중복과 파편화를 해결하고 유지보수성을 개선하기 위한 대규모 리팩토링을 포함합니다. 기존에 여러 곳에 흩어져 있던 토큰 재발급 및 저장 책임을 ReissueAndStoreTokenUseCase로 중앙화하여 코드의 응집도를 높였습니다. 또한, TokenStateManager와 같은 불필요한 상태 관리 로직을 제거하고, TokenAuthenticator의 동시성 제어를 강화하여 토큰 처리의 안정성과 효율성을 향상시켰습니다. 이 변경으로 인해 토큰 관련 오류 처리 및 디버깅이 더욱 용이해질 것입니다.

Highlights

  • 토큰 재발급 및 저장 로직 중앙화: ReissueAndStoreTokenUseCase를 새로 생성하여 토큰 재발급 및 저장 책임을 통합했습니다.
  • TokenAuthenticator 단순화 및 동시성 제어 강화: 재발급 로직을 새로운 UseCase에 위임하고, Mutex를 도입하여 동시 재발급 요청 시 발생할 수 있는 문제를 해결했습니다.
  • TokenStateManager 제거 및 이벤트 기반 전환: 불필요한 애플리케이션 레벨의 토큰 상태 관리 로직(TokenStateManager)을 제거하고, TokenEventBus를 통해 토큰 만료 이벤트를 처리하도록 변경했습니다.
  • OauthRepository.reissueToken 반환 타입 개선: 재발급 실패 원인을 명확히 전달하기 위해 반환 타입을 Token?에서 ApiResult<Token>으로 변경했습니다.
  • 스플래시 화면 로직 단순화: 스플래시 화면에서 토큰 유효성 검사 로직을 제거하고, 헬스체크만 수행하도록 변경하여 초기 로딩 과정을 최적화했습니다.
  • TokenEventBus 안정성 향상: MutableSharedFlowBufferOverflow.DROP_OLDEST 정책을 적용하고 tryEmit을 사용하여 이벤트 발행의 안정성을 높였습니다.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

토큰 재발급 API가 성공(HTTP 200)했지만 응답으로 받은 토큰이 비어있는 경우, 현재 TransientFailure로 처리하고 있습니다. 이 경우 원본 API 요청은 실패하지만 사용자는 로그아웃되지 않습니다. 만약 이것이 일시적인 서버 문제가 아니라 지속적인 문제일 경우, 사용자는 앱의 모든 기능이 실패하는 상태에 머무르게 되어 좋지 않은 사용자 경험을 줄 수 있습니다.

이 엣지 케이스를 복구 불가능한 오류로 간주하여 ReissueAndStoreResult.RefreshInvalid를 반환하도록 변경하는 것이 더 견고한 방법일 것 같습니다. 이렇게 하면 TokenAuthenticator에서 로그아웃 로직이 실행되어 사용자가 다시 로그인할 수 있게 됩니다.

Suggested change
ReissueAndStoreResult.TransientFailure(message = "reissue returned blank tokens")
ReissueAndStoreResult.RefreshInvalid(
responseCode = -1, // HTTP 에러 코드가 아닌 내부 로직 상의 문제임을 표시
message = "reissue returned blank tokens"
)

@HI-JIN2 HI-JIN2 self-assigned this Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants