-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 the ability to provide parameters via urlencoded form #5935
Conversation
Prereq for some things coming later Additionally, adds the ability to disable TLS for test clusters
|
||
// First attempt to get form parameters; if none exist, read the body and | ||
// parse as JSON | ||
err := r.ParseForm() |
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.
This parsing will not have the max_request_size
limiter imposed. Is that something you'd want to put at the start, applicable to both parsing paths?
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.
Yeah, it's true. I guess I should put it behind that, it just makes things a bit more complicated.
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.
Fixed
I believe this will cause surprises for
Instead you have to do:
In the first case, the data is getting parsed as a form with key="[payload.json contents]" value="". |
That may be a totally acceptable tradeoff. You can use |
@jefferai I worry this change would break backwards compatibility for scripts/applications, thoughts? |
Sure, which is why we should probably not merge this yet. |
Stupid question. What if we just check the first character to see if it's |
I think an initial classification of "this looks like it's intended to be JSON, so assume it is" could work. The criteria should probably be something like (as regex): |
All input to Vault is specified as part of a map -- as far as I can recall -- so I think really it would be just checking whether the first rune is |
Yeah, an array input doesn't seem too likely. I think leading whitespace is still something to be considered, however. It's valid JSON and could easily be present, whether via some client or just an errant leading space in a script. |
Closing this for now. We can reopen or create a new PR if we still want to go this route. |
The approach taken is intended to be conservative since we've always assumed JSON and not required Content-Type. Tools and libraries that default to "application/x-www-form-urlencoded" even when JSON is being sent (e.g. curl) will break without these extra backwards compatibility measures. This PR is a reboot of: #5935
Prereq for some things coming later (maybe)
Makes using curl way nicer
Additionally, adds the ability to disable TLS for test clusters