spring-projects / spring-projects/spring-security
Obtaining access tokens in POST request results in a redirect to the original URL
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Describe the bug
When using handling a POST request, it is not possible to obtain a non-cached access_token, neither from @RegisteredOAuth2AuthorizedClient nor from OAuth2AuthorizedClientManager directly.
After the authorization code flow has been executed, Spring Security sends a HTTP 302 to the saved request URL, instead of replaying the request.
To Reproduce
Consider the following controller method
@PostMapping("/some-endpoint")
public String myController(@RegisteredOAuth2AuthorizedClient("spring-auth-server") OAuth2AuthorizedClient authorizedClient) {
// ... your code ...
}
Sending a form POST to this endpoint will trigger the auth code flow, and then end up with a 405 Method not Allowed, with the request body, headers, etc lost.
Expected behavior
The saved request is fully replayed after the auth code flow.
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 by tracing the POST controller example through @RegisteredOAuth2AuthorizedClient and OAuth2AuthorizedClientManager during the authorization-code flow. Verify where the saved request is restored after authentication; done means the original POST, including its method, body, and headers, is replayed instead of redirected as a new request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, authorization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100