Description
Summary
As explained by @wilkinsona in this related issue: spring-projects/spring-boot#17345, a multipartfile request with no authentication to a secure endpoint, results in an AccessDeniedException
(when the HiddenHttpMethodFilter
is disabled). This is handled in ExceptionTranslationFilter.handleSpringSecurityException(HttpServletRequest, HttpServletResponse, FilterChain, RuntimeException)
which results in the creation of a DefaultSavedRequest
. This calls javax.servlet.ServletRequest.getParameterMap()
which causes the multipart request to be consumed and parsed.
Actual Behavior
Multipart file request with no Authentication to a secure endpoint results in the request being parsed and consumed anyway, then the client gets a 401 Unauthorized
Expected Behavior
Multipart file request with no Authentication to a secure endpoint should result in the request not being parsed or consumed, and the client gets a 401 Unauthorized
as soon as an AccessDeniedException
is thrown.
Configuration
Please see the attached sample. You will need to add the property spring.mvc.hiddenmethod.filter.enabled=false
to the application.properties
file
Version
2.1.6.RELEASE
Sample
https://github.com/a-sayyed/spring-jetty-secure-multipartfile-upload-bug