Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider aligning OAuth 2.0 Access Token Response parsing in BodyExtractor #16001

Open
sjohnr opened this issue Oct 25, 2024 · 0 comments
Open
Assignees
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Milestone

Comments

@sjohnr
Copy link
Member

sjohnr commented Oct 25, 2024

For reactive applications, the default implementation of BodyExtractor<Mono<OAuth2AccessTokenResponse>, ReactiveHttpInputMessage> used by AbstractWebClientReactiveOAuth2AccessTokenResponseClient is OAuth2BodyExtractors.oauth2AccessTokenResponse(). It uses Nimbus to parse an OAuth 2.0 Access Token Response.

The Nimbus implementation determines if the response is success or failure based solely on parameters in the response. By contrast, for servlet applications, a RestTemplate or RestClient uses an error handler that is invoked based on the HTTP status code of the response. This means that handling of an OAuth 2.0 Error Response in particular is not aligned between the two stacks. It would be nice if we could align error handling. Further, on the reactive side, parsing is tied into error handling and applications that wish to customize one must customize both in an inconsistent way.

We could also consider re-using the parsing logic from the servlet stack in the BodyExtractor for reactive:

  • DefaultMapOAuth2AccessTokenResponseConverter can be re-used for converting response parameters to an OAuth2AccessTokenResponse
  • OAuth2ErrorConverter (currently a private inner class of OAuth2ErrorHttpMessageConverter) can be re-used for converting error parameters to an OAuth2Error
@sjohnr sjohnr added type: enhancement A general enhancement in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) labels Oct 25, 2024
@sjohnr sjohnr self-assigned this Oct 25, 2024
@sjohnr sjohnr added this to the 6.5.x milestone Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Projects
Status: No status
Development

No branches or pull requests

1 participant