Skip to content

Prevent concurrent OAuth2 client authorization requests - #19523

Open
yashdotdev13 wants to merge 1 commit into
spring-projects:mainfrom
yashdotdev13:fix/reactive-oauth2-token-race
Open

Prevent concurrent OAuth2 client authorization requests#19523
yashdotdev13 wants to merge 1 commit into
spring-projects:mainfrom
yashdotdev13:fix/reactive-oauth2-token-race

Conversation

@yashdotdev13

Copy link
Copy Markdown

Summary

Prevent duplicate OAuth2 client authorization requests when multiple threads concurrently authorize the same client registration and principal.

Changes

  • Coordinate in-flight authorization requests using OAuth2AuthorizedClientId and CompletableFuture.
  • Ensure only one concurrent request invokes the OAuth2AuthorizedClientProvider for a given client registration and principal.
  • Have concurrent callers wait for and reuse the in-flight authorization result.
  • Propagate authorization failures to waiting callers and remove completed in-flight requests safely.
  • Add a regression test covering concurrent authorization.

Validation

  • ./gradlew :spring-security-oauth2-client:check
  • ./gradlew :spring-security-oauth2-client:test
  • ./gradlew :spring-security-oauth2-client:checkstyleMain :spring-security-oauth2-client:checkstyleTest

The branch was rebased onto the latest upstream/main before publishing.

Signed-off-by: Yash Chauhan <yashchauhan.gaya@gmail.com>
@yashdotdev13
yashdotdev13 force-pushed the fix/reactive-oauth2-token-race branch from 96a1542 to 0b072ce Compare August 11, 2026 13:15
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants