Skip to content

๐Ÿ”€ :: (#952) ํ† ํฐ ์žฌ๋ฐœ๊ธ‰ ์ค‘๋ณต ํ˜ธ์ถœ ๋ฌธ์ œ ํ•ด๊ฒฐ#953

Merged
ashxom merged 9 commits into
developfrom
bug/952-ํ† ํฐ-์žฌ๋ฐœ๊ธ‰-์ค‘๋ณต-ํ˜ธ์ถœ-๋ฌธ์ œ-ํ•ด๊ฒฐ
Jun 19, 2026

Hidden character warning

The head ref may contain hidden characters: "bug/952-\ud1a0\ud070-\uc7ac\ubc1c\uae09-\uc911\ubcf5-\ud638\ucd9c-\ubb38\uc81c-\ud574\uacb0"
Merged

๐Ÿ”€ :: (#952) ํ† ํฐ ์žฌ๋ฐœ๊ธ‰ ์ค‘๋ณต ํ˜ธ์ถœ ๋ฌธ์ œ ํ•ด๊ฒฐ#953
ashxom merged 9 commits into
developfrom
bug/952-ํ† ํฐ-์žฌ๋ฐœ๊ธ‰-์ค‘๋ณต-ํ˜ธ์ถœ-๋ฌธ์ œ-ํ•ด๊ฒฐ

Conversation

@ashxom

@ashxom ashxom commented Jun 19, 2026

Copy link
Copy Markdown
Member

๊ฐœ์š”

refresh token์˜ ์ค‘๋ณต ์‚ฌ์šฉ์œผ๋กœ ๋กœ๊ทธ์•„์›ƒ๋˜๋Š” ๋ฌธ์ œ๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ํ† ํฐ ์žฌ๋ฐœ๊ธ‰ ๋กœ์ง์˜ ์•ˆ์ •์„ฑ์„ ๊ฐœ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.

์ž‘์—…์‚ฌํ•ญ

  • ๋™์‹œ 401 ์‘๋‹ต ๋ฐœ์ƒ ์‹œ ํ† ํฐ ์žฌ๋ฐœ๊ธ‰์ด ์ค‘๋ณต ํ˜ธ์ถœ๋˜์ง€ ์•Š๋„๋ก ์ˆ˜์ •
  • ์ด๋ฏธ ๊ฐฑ์‹ ๋œ access token์ด ์žˆ์œผ๋ฉด ์žฌ๋ฐœ๊ธ‰ ์—†์ด ์žฌ์‚ฌ์šฉํ•˜๋„๋ก ๋ณ€๊ฒฝ
  • ์„ธ์…˜ ๊ฐฑ์‹  ์„ฑ๊ณต ์—ฌ๋ถ€๋ฅผ ์œ ํšจํ•œ access token ๊ธฐ์ค€์œผ๋กœ ํŒ๋‹จํ•˜๋„๋ก ์ˆ˜์ •

์ถ”๊ฐ€ ๋กœ ํ•  ๋ง

Summary by CodeRabbit

  • Refactor
    • Improved cached token and session refresh behavior to align outcomes with current token availability.
    • Streamlined authorization handling so refreshed credentials only replace the request header when needed.
  • Bug Fixes
    • Improved network response resource handling during token reissue to prevent leaks and ensure consistent failure behavior.
  • Security
    • Strengthened validation to avoid unnecessary authorization header updates when a refresh does not produce a new token.

@ashxom ashxom self-assigned this Jun 19, 2026
@ashxom ashxom added the ๐Ÿ‘พbug ๋ฒ„๊ทธ๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒฝ์šฐ label Jun 19, 2026
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ashxom, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 46 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running โ€” you're only billed for reviews past your plan's rate limits ($0.25/file).

โŒ› How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

๐Ÿšฆ How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

โ„น๏ธ Review info
โš™๏ธ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3923093e-44a8-45cc-967f-b58187e89660

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between d1238f8 and d874995.

๐Ÿ“’ Files selected for processing (2)
  • core/jwt/src/main/java/team/aliens/dms/android/core/jwt/network/authenticator/JwtAuthenticator.kt
  • core/jwt/src/main/java/team/aliens/dms/android/core/jwt/network/interceptor/JwtInterceptor.kt
๐Ÿ“ Walkthrough

Walkthrough

Refactors JwtProviderImpl token getter expressions, availability StateFlow backing fields, and session resolution boolean return conditions. Updates JwtReissueManager to annotate its URL parameter with @TokenReissueUrl and wrap the HTTP response in a use {} block. Reworks JwtAuthenticator to capture the failed authorization header and skip redundant token refreshes when a newer cached token already exists.

Changes

JWT Core Refactor

Layer / File(s) Summary
Token getters and availability state flows
core/jwt/.../JwtProviderImpl.kt
cachedAccessToken and cachedRefreshToken getters rewritten with local val bindings and null/expiry throws; _isCachedAccessTokenAvailable and _isCachedRefreshTokenAvailable refactored as backing MutableStateFlows exposed via asStateFlow(); loadTokens() assigns cached fields directly and calls refreshTokenAbility() after load.
Session resolution and refresh return logic
core/jwt/.../JwtProviderImpl.kt
resolveSession() and refreshSession() converted to withLock expression bodies; return condition changed from checkIsAccessTokenAvailable() || checkIsRefreshTokenAvailable() to reissued && checkIsAccessTokenAvailable(); resolveSession() short-circuits with true for non-expired cached access tokens; availability check helpers simplified to nullable-safe expressions.
Token reissue, persistence, and rollback
core/jwt/.../JwtProviderImpl.kt
reissueTokensLocked() calls jwtReissueManager with refreshToken.value, catches CannotReissueTokenException on 401/404 by invoking clearCachesLocked(); updateTokensLocked() and clearCachesLocked() reformatted with direct _cached* assignments, preserving rollback pattern and IllegalStateException throws on persistence failure.
JwtReissueManager URL qualifier and response resource management
core/jwt/.../network/JwtReissueManager.kt
Constructor parameter annotated with @TokenReissueUrl; OkHttp execute() call wrapped in response.use {} to guarantee response closure; private helpers for body deserialization and request construction restructured for readability without behavioral change.
JwtAuthenticator retry de-duplication and ignore logic
core/jwt/.../network/authenticator/JwtAuthenticator.kt
authenticate() captures failedAuthorization header and skips header update when refreshAuthorization returns the same value; refreshAuthorization(failedAuthorization) short-circuits to cached token when it already differs from the failed header, otherwise refreshes session; shouldBeIgnored rewritten with explicit path/method/isIgnoredRequest variables; checkS3Request converted to expression body.

Estimated code review effort

๐ŸŽฏ 3 (Moderate) | โฑ๏ธ ~25 minutes

Possibly related PRs

  • team-aliens/DMS-Android#828: Modifies JwtProviderImpl token availability/refresh and JwtReissueManager reissue/exception handling, which directly overlaps with the same classes changed in this PR.
  • team-aliens/DMS-Android#877: Changes JwtProviderImpl.reissueTokens() error handling for CannotReissueTokenException (cache clearing on 401 vs 401/404), directly intersecting with this PR's reissueTokensLocked/clearCachesLocked refactor.
  • team-aliens/DMS-Android#908: Modifies JwtProviderImpl's refreshSession/session-resolution boolean logic and JwtAuthenticator's refresh/authorization retry behavior, covering the same code paths changed here.

Poem

๐Ÿ‡ Hoppity-hop through token land,
No more stale auth slipping through my hand!
The cached bearer meets its failed twin,
A use {} block keeps responses thin.
reissued && available โ€” what a neat gate,
This bunny's JWT flow is finally great! ๐Ÿ”

๐Ÿšฅ 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
Description Check โœ… Passed Check skipped - CodeRabbitโ€™s high-level summary is enabled.
Title check โœ… Passed The title directly addresses the main objective: preventing duplicate token reissuance calls. It matches the core purpose of the changeset.
Linked Issues check โœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check โœ… Passed Check skipped because no linked issues were found for this pull request.

โœ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.

โœจ Finishing Touches
๐Ÿงช Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bug/952-ํ† ํฐ-์žฌ๋ฐœ๊ธ‰-์ค‘๋ณต-ํ˜ธ์ถœ-๋ฌธ์ œ-ํ•ด๊ฒฐ

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 and usage tips.

@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: 1

๐Ÿค– 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
`@core/jwt/src/main/java/team/aliens/dms/android/core/jwt/network/authenticator/JwtAuthenticator.kt`:
- Around line 77-86: The checkS3Request(url.toString()) call is currently placed
inside the any() lambda predicate, which means it will never be evaluated if
ignoreRequests.requests is empty since the any() function short-circuits without
executing the lambda. Move the S3 request check outside of the any() loop in the
shouldBeIgnored() method so that checkS3Request is always evaluated
independently, allowing S3 requests to be properly ignored regardless of whether
there are other ignore requests configured.
๐Ÿช„ 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: b8c0415b-fb5d-4cd1-b915-66d99d97a4eb

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 5a7007a and eb71c5d.

๐Ÿ“’ Files selected for processing (3)
  • core/jwt/src/main/java/team/aliens/dms/android/core/jwt/JwtProviderImpl.kt
  • core/jwt/src/main/java/team/aliens/dms/android/core/jwt/network/JwtReissueManager.kt
  • core/jwt/src/main/java/team/aliens/dms/android/core/jwt/network/authenticator/JwtAuthenticator.kt

@ashxom
ashxom merged commit 46f1f68 into develop Jun 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

๐Ÿ‘พbug ๋ฒ„๊ทธ๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒฝ์šฐ

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ํ† ํฐ ์žฌ๋ฐœ๊ธ‰ ์ค‘๋ณต ํ˜ธ์ถœ ๋ฌธ์ œ ํ•ด๊ฒฐ

1 participant