Repository navigation
[Client] Keep a client another worker registered when dropping a refused one - #725
Merged
chr-hertel merged 1 commit intoNov 10, 2026
Conversation
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
November 10, 2026 09:52
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The supplied review evidence identifies no active issues with the OAuth client cleanup race fix.
No open issues 🎉
What changed in this PR
This PR fixes an OAuth client cleanup race so an invalid_client response does not delete a replacement registration and its tokens saved by another worker.
Changes:
- Check the stored client ID and remove the refused registration under the registration lock, covering both refresh and authorization-code exchange failures.
- Add regression tests that simulate another worker replacing the registration.
| File | Description |
|---|---|
tests/Unit/Client/Auth/OAuthAuthenticatorTest.php |
Adds concurrent-registration regression tests and a storage double. |
src/Client/Auth/OAuthAuthenticator.php |
Adds synchronized, client-ID-checked cleanup at both failure paths. |
Review effort: Balanced
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.
When the token endpoint answers
invalid_clientfor a dynamically registered client, the authenticator drops the registration of the issuer. It did that without checking whether the stored registration is still the client that was refused - so if another worker registered a new client in the meantime, that one got dropped, together with its tokens.The approach:
forgetRefusedClient()only forgets the issuer if the stored registration still has the client id that was refusedforget()run insidestorage->synchronize()- the same lockresolveClient()holds while it registers, so no registration can land in betweenThe tests use a storage double that swaps in another worker's registration right after the authenticator picked up the old one. Without the fix the refresh registers a third client and the code exchange drops the other worker's one.
Spotted while reviewing #660, which needs the same for a deferred callback.