add shape headers to CORS expose headers #11650
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This was supposed to be a hackathon project that I forgot to present. This is related to #11587 and #11577.
We can make use of the specs to automatically expose headers as given by the specs for a specific operation, instead of adding them one by one.
This also adds a small fix related to the
Allow-Headers
, as we were trying to access the response headers instead of the request header. I'm not too sure of the existing behavior here to be honest, as it effectively always adds the headers, so the existing list is not really needed.We could maybe also always use
*
for Expose headers (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers), as I'm not sure we have a lot of security issues regarding this, and it might just be way lighter than accessing the specs.In any case, this additional logic is only executed when the request has a
Origin
header, so when it's coming from a browser, so it shouldn't impact performance in other cases.The problem with testing is that not many service operations actually return headers, there is the Lambda case in case of exception, but for this you need to actually call
lambda.Invoke
and get an execution failure, which isn't too adapted to thetest_security.py
file...\cc @dfangl @webdev51
Changes
Expose
CORS headers