Fix CORS behaviour if there is no origin header #439
Merged
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.
The CORS origin header handling fell back to an empty header value. This value is considered valid for
Origin::Any
(wildcard origin). However, if the CORS middleware is restricted to a whitelist of origins, theis_valid_origin
check correctly fails for an empty origin headervalue. Though, since we fell back to an empty value when there is no origin header at all, we fail the validation and consequentially respond with a 403 (forbidden) to such requests.
The CORS specifications stats the following for simple cross-origin requests, actual requests and preflight requests:
This PR therefore updates the CORS middleware to ignore requests that have no origin header set.