spring-projects / spring-projects/spring-security
Consider aligning OAuth 2.0 Access Token Response parsing in BodyExtractor
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
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:
DefaultMapOAuth2AccessTokenResponseConvertercan be re-used for converting response parameters to anOAuth2AccessTokenResponseOAuth2ErrorConverter(currently a private inner class ofOAuth2ErrorHttpMessageConverter) can be re-used for converting error parameters to anOAuth2Error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AbstractWebClientReactiveOAuth2AccessTokenResponseClient and OAuth2BodyExtractors.oauth2AccessTokenResponse(), then compare their Nimbus parsing with DefaultMapOAuth2AccessTokenResponseConverter and OAuth2ErrorConverter from the servlet stack. Review OAuth2ErrorHttpMessageConverter as the current location of the error converter. Done should align reactive and servlet OAuth 2.0 error handling while allowing parsing and error handling to be customized independently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100