Description
Currently when you make a POST
request for a file upload on a secure endpoint, the Underlying Jetty Server consumes the whole file first then passes the request to Spring security. This means that security is checked after the file is already uploaded.
To replicate this issue, you can clone the demo repository I have created and simply upload a file to the endpoint /upload
with no authentication, you can see in the logs that the inputstream from the file is getting consumed by Jetty before the request is checked for Authentication.
The spring.servlet.multipart.resolve-lazily
property is also not respected.
For testing, (on a linux machine), you can create a random file with the command head -c 256MB /dev/urandom > randomFile.txt
If you would like to try the request out with authentication, the credentials are admin:admin