Repository navigation
fix(wp-native-auth): reuse grace window for refresh-token retries after a lost response - #132
Merged
Merged
Conversation
…er a lost response A client whose refresh request timed out after the server rotated still holds the superseded token. Its retry was treated as theft and revoked the whole token family, forcing a re-login. Within wp_native_auth_refresh_reuse_grace_seconds (default 60s, 0 disables) of the rotation, re-presenting the superseded token now returns a freshly rotated pair. The window is anchored to the original rotation and is not extended by retries; outside it, or for a revoked family, replay still revokes the family. A concurrent 0-rows race inside the window returns a retryable refresh_in_progress (OAuth temporarily_unavailable 503) instead of revoking. The OAuth invalid_grant 400 status is pinned by a test. Fixes #131
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #131.
Why
On 2026-12-02 an overloaded server rotated a refresh token, but the client (Roadie) timed out before it got the response and retried with the superseded token. Reuse detection revoked the whole family, and every refresh after that returned
invalid_grant, which locked the person out of their MCP tools. Client side: Extra-Chill/roadie#496.What
wp_native_auth_refresh_reuse_grace_seconds(constantWP_NATIVE_AUTH_REFRESH_REUSE_GRACE_SECONDS= 60,0disables), pluswp_native_auth_refresh_reuse_in_grace().prev_token_hashkeeps the client-held token, andlast_used_atstays at the original rotation time, so retries never extend the window. Outside the window, or for a revoked family, the family is still revoked as before.refresh_in_progress(409; on the OAuth pathtemporarily_unavailable503) and does not revoke. Outside the window it revokes as before./tokenreturning 400invalid_grantis correct per RFC 6749 §5.2. The native route keeps 401. Both are now pinned by a test.Tests
test-refresh-reuse-detection.php: a retry inside the window gets a fresh pair, the family survives, and the new pair keeps working. Retries don't extend the window, and a late replay revokes. Filter 0 disables the window. A revoked family gets no grace. The existing reuse and concurrency tests now age the row or disable grace.test-oauth-token.php: grace retry through the OAuth path; reuse returnsinvalid_grantwith a 400 status.test-push-tokens.php: the family-revocation test runs with grace disabled.tests/reuse-grace-standalone-smoke.php(in the manifest) exercises the realwp_native_auth_refresh_reuse_in_grace(). It passes locally, andphp -lis clean.AI disclosure: written by Extra Chill Bot (Claude) via direct fallback outside Homeboy (homeboy-lab overloaded, Extra-Chill/homeboy#19733), authorized by @Chubes.