-
Notifications
You must be signed in to change notification settings - Fork 6k
In the UsernamePasswordAuthenticationFilter, the authRequest is added as an attribute to the HttpServletRequest. #16444
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
Comments
I think that a better way to do this would be to add a new optional property What do you think? Would you be interested in creating a pull request for this? |
I'm interested, so I'll try to send a PR over the weekend. |
Store the authentication request details in the `authRequest` field of `AuthenticationException` when an authentication exception occurs. Closes gh-16444 Signed-off-by: amm0124 <amm0124@naver.com>
Store the authentication request details in the `authRequest` field of `AuthenticationException` when an authentication exception occurs. Closes spring-projectsgh-16444 Signed-off-by: amm0124 <amm0124@naver.com>
Store the authentication request details in the `authRequest` field of `AuthenticationException` when an authentication exception occurs. Closes spring-projectsgh-16444 Signed-off-by: amm0124 <amm0124@naver.com>
- Add getter for reading the request - Update BadCredentialsMixing to ignore authentication - Allow exception to be mutable Issue spring-projectsgh-16444
Store the authentication request details in the `authRequest` field of `AuthenticationException` when an authentication exception occurs. Closes spring-projectsgh-16444 Signed-off-by: amm0124 <amm0124@naver.com>
- Add getter for reading the request - Update BadCredentialsMixing to ignore authentication - Allow exception to be mutable Issue spring-projectsgh-16444
- Isolated exception construction - Isolated entry point subscription Issue spring-projectsgh-16444
- Add getter for reading the request - Update BadCredentialsMixing to ignore authentication - Allow exception to be mutable Issue gh-16444
- Isolated exception construction - Isolated entry point subscription Issue gh-16444
Expected Behavior
You expect to receive username and password in the application/json format and be able to extract them again in the unsuccessHandler.
In traditional HTML forms, the default encoding is x-www-urlencoded, but nowadays, application/json format is more commonly preferred in web development. While it is up to the developer to customize UsernamePasswordAuthenticationFilter to handle application/json format for username and password, an issue arises.
The HttpServletRequest in application/json format is a consumable stream, meaning once the data is extracted, it cannot be extracted again. This leads to a problem where, in the unsuccessHandler, you are unable to perform subsequent actions (e.g., incrementing account error counts for the username) because the stream has already been consumed.
To solve this problem, developers may find that completely customizing the filter is inefficient and means they are missing out on useful functionality provided by Spring Security.
Therefore, if authRequest is saved in the HttpServletRequest in UsernamePasswordAuthenticationFilter, it would resolve this issue.
Context
After receiving the login credentials in the application/json format for form login, you'd like to use the username and password in the unsuccessHandler for subsequent processing like error count increments.
The text was updated successfully, but these errors were encountered: