Skip to content

Fix remember-me token resynchronization#10015

Closed
ruibaby wants to merge 1 commit into
halo-dev:mainfrom
ruibaby:fix/remember-me-previous-token
Closed

Fix remember-me token resynchronization#10015
ruibaby wants to merge 1 commit into
halo-dev:mainfrom
ruibaby:fix/remember-me-previous-token

Conversation

@ruibaby

@ruibaby ruibaby commented May 21, 2026

Copy link
Copy Markdown
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR adjusts persistent remember-me token validation so a request presenting the previous token value is treated as a stale-but-recoverable token instead of cookie theft.

When a remember-me token is rotated, another in-flight request, restored tab, or cached response can still present the previous token value. The previous token is already stored on the RememberMeToken extension, so accepting it preserves the intended rotation safety while avoiding false-positive CookieTheftException handling that deletes all remember-me tokens for the user.

When the previous token is accepted, Halo now writes the current remember-me token back to the response cookie so the browser can resynchronize.

Which issue(s) this PR fixes:

N/A

Special notes for your reviewer:

Validated against production logs showing a previous token value being presented after rotation and later treated as cookie theft. The change still rejects token values that match neither the current nor previous token.

This PR was prepared with AI assistance and reviewed locally.

Checks run:

./gradlew :application:test --tests "run.halo.app.security.authentication.rememberme.PersistentTokenBasedRememberMeServicesTest"
./gradlew :application:spotlessApply
git diff --check

Does this PR introduce a user-facing change?

Fixed an issue where remember-me authentication could incorrectly expire user login sessions after token rotation.

@f2c-ci-robot f2c-ci-robot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. labels May 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

@f2c-ci-robot

f2c-ci-robot Bot commented May 21, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ruibaby for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.03%. Comparing base (42c374d) to head (b5d66b3).
⚠️ Report is 588 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #10015      +/-   ##
============================================
+ Coverage     59.55%   61.03%   +1.47%     
- Complexity     3812     4089     +277     
============================================
  Files           677      706      +29     
  Lines         23248    23768     +520     
  Branches       1500     1562      +62     
============================================
+ Hits          13846    14506     +660     
+ Misses         8764     8515     -249     
- Partials        638      747     +109     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ruibaby ruibaby closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant