Skip to content
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

Add support for multipart/form-data #285

Open
flower-of-the-bridges opened this issue Oct 24, 2023 · 3 comments
Open

Add support for multipart/form-data #285

flower-of-the-bridges opened this issue Oct 24, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@flower-of-the-bridges
Copy link

Is your feature request related to a problem? Please describe

At the moment, body requests that are not of type application/json will be discarded by the policy.

Describe the solution you'd like

It would be nice if the parameters of a multipart/form-data requests will be parsed into the input object

Describe alternatives you've considered

Additional context

@fredmaggiowski fredmaggiowski added good first issue Good for newcomers enhancement New feature or request labels Oct 25, 2023
@fredmaggiowski
Copy link
Member

Hi @flower-of-the-bridges multipart/form-data can contain both binary data and metadata associated with them; do you need the whole body or just the metadata?

@flower-of-the-bridges
Copy link
Author

flower-of-the-bridges commented Oct 26, 2023

Hi @fredmaggiowski

Yes what I'd like is to extract some metadata (except for binary content) and make some policies with its value.

For example, If I make a request like this:

POST /my-multipart-endpoint 
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; my_metadata="my_metadata_value"
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="myfile.txt"
Content-Type: <Content-Type header here>

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--

I'd like to accomplish is to access the value my_metadata_value from a key my_metadata contained in the input.request.body object.

For example, a policy that will test whether the header is correct will be something like this:

package policies

check_form_metadata {
   input.request.body.metadata == "some_value"
}

@fredmaggiowski
Copy link
Member

Yes what I'd like is to extract some metadata (except for binary content) and make some policies with its value.

OK thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants