fix(auth): cap CLI JWT refresh to original 30-day lifetime#129
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 54 minutes and 42 seconds. Learn how PR review limits work. Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
The previous assertion expected second?.refreshedToken to be null, but a token past its 30-day cap is rejected outright (verify returns null), so the optional chain yielded undefined. Decode the refreshed token's exp and assert it equals the original expiry, then assert rejection past 30 days. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2c571f6 to
1f30f82
Compare
|
Merged. Caps CLI JWT refresh to the original 30-day lifetime so a leaked token can't be chained indefinitely via the sliding refresh. |
Motivation
Description
oiat(original issued-at) claim and extendedcreateCliTokento accept an optionaloriginalIatso refreshed tokens preserve the original issuance anchor viaoiatand do not push the absolute expiry forward.expas the minimum of the normal 30-day expiry and the absolute expiry derived fromoiat, and added theoiatfield into the payload.verifyCliTokenWithRefreshto computeoriginalIatandabsoluteAgeSecondsand only mint a refreshed token when the token is past the refresh threshold and still within the original 30-day lifetime, passingoriginalIatthrough when creating the refreshed token.does not extend lifetime beyond the original 30 daysinapps/web/__tests__/unit/cli-auth.test.tsto assert refreshed tokens cannot be chained past the initial 30-day window.Testing
apps/web/__tests__/unit/cli-auth.test.tsthat verifies refresh behavior and the new non-chainable lifetime guard.pnpm -C apps/web vitest __tests__/unit/cli-auth.test.tsfailed due to an unsupported package manager specification andcd apps/web && bun x vitest __tests__/unit/cli-auth.test.tsfailed with npm registry access (HTTP 403), so tests could not be executed in this runner.Codex Task