-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Update CSRF filter to support multipart/form-data payloads #28383
Update CSRF filter to support multipart/form-data payloads #28383
Conversation
This comment has been minimized.
This comment has been minimized.
I can probably add another test template to produce a multipart/form-data |
a6ecc98
to
26999b1
Compare
@FroMage CSRF feature can only partially help when dealing with multipart/form-data - it will help with generating a token and getting it injected into a user template. This is because, as opposed to a form urlencoded payload, reading the multipart payload in the filter and then restoring is not realistic, as most likely it will have file(s) submitted. But indeed even with large forms reading and restoring can be of concern, so we already recommend in docs in such cases to do the verification in the actual endpoint code - check the form token param against the cookie, but it looks like it does not work yet with RestEasy reactive, so I'll open another issue |
This comment has been minimized.
This comment has been minimized.
26999b1
to
1113312
Compare
Note by default the filter will cover the whole application URI space for POST payloads, and enforce that the forms are url encoded, so a few properties exist to specify which path has to be protected (I made it a Set in this PR), and whether, when the filter verification is enabled, some other payloads should be allowed which is useful in a test where a token verification is required for one method, but for the other one it is delayed till the endpoint is invoked |
1113312
to
25c7b05
Compare
Tests look good now after the fix from Georgios |
From your code, I don't see where you verify the token automatically for anything but url-encoded forms. It doesn't look like you added support for multipart forms. As for restoring the forms, I thought you didn't need to do that, since Vert.x was responsible for reading and caching them. |
@FroMage Hi,
I agree, I was just about to rename the PR, which currently is to verify that the CSRF filter can only help with generating the tokens and having them injected in the template. But...
changes everything :-), if that is the case then I'll be happy to get rid of the code which restores the forms and that will also help with auto-verification in case of the multipart/form-data, let me try |
25c7b05
to
6a8176a
Compare
@FroMage This is very good, thanks, I was able to get rid of the code which restores the form stream, glad you've pointed it out :-) The tokens in |
This comment has been minimized.
This comment has been minimized.
6a8176a
to
d63a8c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Fixes #28379