Skip to content

fix: never refresh OAuth token without the config lock - #1021

Open
amanharshx wants to merge 1 commit into
railwayapp:masterfrom
amanharshx:fix/oauth-refresh-unlocked-race
Open

fix: never refresh OAuth token without the config lock#1021
amanharshx wants to merge 1 commit into
railwayapp:masterfrom
amanharshx:fix/oauth-refresh-unlocked-race

Conversation

@amanharshx

Copy link
Copy Markdown

When the config lock can't be acquired, ensure_valid_token now returns a retryable ConfigLockBusy error instead of refreshing unlocked. An unlocked refresh lets a parallel process present an already-rotated refresh token, which the server treats as reuse and revokes the whole grant (a hard logout). A retry is cheap and recoverable, but a revoked grant is not.

On config-lock acquisition failure, ensure_valid_token now returns a retryable ConfigLockBusy error instead of refreshing unlocked. Refreshing without the lock lets a parallel process present an already-rotated refresh token, which the server treats as reuse and revokes the entire grant (a hard logout). A retry is cheap and recoverable; a revoked grant is not.

Also always reload + re-check expiry under the lock, split ConfigLockGuard::acquire into a testable acquire_at, and drop the misleading unlocked-refresh warning.
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.

1 participant