Repository navigation
conformance test: CORS - #4494
Conversation
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
|
do not unhold :D @DamianSawicki is fixing the GEP and we will be fixing this conformance test. I am aware that this may break current passing implementations (some of those I fixed yesterday, and will need another fix) but we want the feature to be as close as possible of the specs! |
As per kubernetes-sigs#4494 (comment) Mozilla has an example where in response to an uncredentialed request, the server responds with `Access-Control-Allow-Origin: *`. However, responding with the value of the Origin from the request is also valid (and the only allowed behavior for credentialed requests), and it is the behavior of some implementations as per https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401 so let's relax the requirement in the GEP to allow it.
Thanks @rikatz and @DamianSawicki! /lgtm cancel |
* Remove implementation-specific methods/headers Previously, the GEP mentioned allowing "implementatio-specific default methods and headers". It's not obvious what that means, but my understanding is that this would allow implementations to arbitrarily add certain values (not specified by the user) to the headers Access-Control-Allow-Methods and Access-Control-Request-Headers`. It does not seem to be needed. We can revisit this aspect if it turns out otherwise. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Unify gep-1767 and httproute_types.go It seems that not all changes in GEP 1767 were correctly reflected in apis/v1/httproute_types.go. This is now fixed. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Allow specific Allow-Origin despite wildcard As per #4494 (comment) Mozilla has an example where in response to an uncredentialed request, the server responds with `Access-Control-Allow-Origin: *`. However, responding with the value of the Origin from the request is also valid (and the only allowed behavior for credentialed requests), and it is the behavior of some implementations as per https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401 so let's relax the requirement in the GEP to allow it. * Allow specific Allow-Methods despite wildcard As per https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#syntax wildcard is a valid value for the Access-Control-Allow-Methods header. However, as per * envoyproxy/envoy#8218 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#browser_compatibility the wildcard was not universally supported by browsers in 2019, and hence many implementations don't use the wildcard. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Reword comment for allowHeaders to match methods Signed-off-by: Damian Sawicki <dsawicki@google.com> * Copy validation for * from allowMethods to headers This uniformizes the validation for allowMethods and allowHeaders by requiring that when '*' appears in allowHeaders, it must be the only value in the list. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Add section on wildcards to GEP 1767 Signed-off-by: Damian Sawicki <dsawicki@google.com> * Update GEP 1767 metadata with new PR Signed-off-by: Damian Sawicki <dsawicki@google.com> --------- Signed-off-by: Damian Sawicki <dsawicki@google.com>
As per kubernetes-sigs#4494 (comment) Mozilla has an example where in response to an uncredentialed request, the server responds with `Access-Control-Allow-Origin: *`. However, responding with the value of the Origin from the request is also valid (and the only allowed behavior for credentialed requests), and it is the behavior of some implementations as per https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401 so let's relax the requirement in the GEP to allow it.
|
/hold cancel Istio (on main) and Envou Gateway are passing with the current tests, the missing pieces are actually making the headers more permissive, which I think we can make if some implementation feels they should be sending wildcard methods instead of specific methods. CORS is a bit tricky, because it actually relies not on the server sending the right information always, but on the browser trusting it. Envoy wise, all the wildcards passed as requests (methods, headers) are answered echoing the request or hiding the header in case it does not match the request from the user. |
* Remove implementation-specific methods/headers Previously, the GEP mentioned allowing "implementatio-specific default methods and headers". It's not obvious what that means, but my understanding is that this would allow implementations to arbitrarily add certain values (not specified by the user) to the headers Access-Control-Allow-Methods and Access-Control-Request-Headers`. It does not seem to be needed. We can revisit this aspect if it turns out otherwise. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Unify gep-1767 and httproute_types.go It seems that not all changes in GEP 1767 were correctly reflected in apis/v1/httproute_types.go. This is now fixed. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Allow specific Allow-Origin despite wildcard As per #4494 (comment) Mozilla has an example where in response to an uncredentialed request, the server responds with `Access-Control-Allow-Origin: *`. However, responding with the value of the Origin from the request is also valid (and the only allowed behavior for credentialed requests), and it is the behavior of some implementations as per https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401 so let's relax the requirement in the GEP to allow it. * Allow specific Allow-Methods despite wildcard As per https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#syntax wildcard is a valid value for the Access-Control-Allow-Methods header. However, as per * envoyproxy/envoy#8218 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#browser_compatibility the wildcard was not universally supported by browsers in 2019, and hence many implementations don't use the wildcard. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Reword comment for allowHeaders to match methods Signed-off-by: Damian Sawicki <dsawicki@google.com> * Copy validation for * from allowMethods to headers This uniformizes the validation for allowMethods and allowHeaders by requiring that when '*' appears in allowHeaders, it must be the only value in the list. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Add section on wildcards to GEP 1767 Signed-off-by: Damian Sawicki <dsawicki@google.com> * Update GEP 1767 metadata with new PR Signed-off-by: Damian Sawicki <dsawicki@google.com> --------- Signed-off-by: Damian Sawicki <dsawicki@google.com> Co-authored-by: Damian Sawicki <dsawicki@google.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rikatz, robscott The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Hi @rikatz thanks for taking this on. I tested it against Envoy Gateway v1.7.0 and it passed. |
|
Hi @rikatz, I can confirm that Airlock Microgateway 4.8 also passes these tests in their current state. |
|
Thanks @rikatz! /lgtm |
|
/cherry-pick release-1.5 |
|
@rikatz: #4494 failed to apply on top of branch "release-1.5": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
* add test for cors Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * add more tests Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * Update conformance/tests/httproute-cors.go Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com> * Update conformance/tests/httproute-cors.go Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com> * Add option to ignore whitespace in the resposnse header values Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * support multiple status codes Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address some comments * Add wildcard test on cors * Add more tests to CORS * Add more CORS conformance tests * address comments on cors tests --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
* add test for cors * add more tests * address comment * address comment * Update conformance/tests/httproute-cors.go * Update conformance/tests/httproute-cors.go * Add option to ignore whitespace in the resposnse header values * support multiple status codes * address comment * address comment * fix lint * fix test * address comment * address comments * address comments * address comments * address comments * address comments * address comments * address comments * address some comments * Add wildcard test on cors * Add more tests to CORS * Add more CORS conformance tests * address comments on cors tests --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
* Remove implementation-specific methods/headers Previously, the GEP mentioned allowing "implementatio-specific default methods and headers". It's not obvious what that means, but my understanding is that this would allow implementations to arbitrarily add certain values (not specified by the user) to the headers Access-Control-Allow-Methods and Access-Control-Request-Headers`. It does not seem to be needed. We can revisit this aspect if it turns out otherwise. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Unify gep-1767 and httproute_types.go It seems that not all changes in GEP 1767 were correctly reflected in apis/v1/httproute_types.go. This is now fixed. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Allow specific Allow-Origin despite wildcard As per kubernetes-sigs#4494 (comment) Mozilla has an example where in response to an uncredentialed request, the server responds with `Access-Control-Allow-Origin: *`. However, responding with the value of the Origin from the request is also valid (and the only allowed behavior for credentialed requests), and it is the behavior of some implementations as per https://github.com/kubernetes-sigs/gateway-api/blob/b1a7a927b098a4ab99c3bf9983412cb2f1a419fd/conformance/tests/httproute-cors.go#L399-L401 so let's relax the requirement in the GEP to allow it. * Allow specific Allow-Methods despite wildcard As per https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#syntax wildcard is a valid value for the Access-Control-Allow-Methods header. However, as per * envoyproxy/envoy#8218 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Methods#browser_compatibility the wildcard was not universally supported by browsers in 2019, and hence many implementations don't use the wildcard. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Reword comment for allowHeaders to match methods Signed-off-by: Damian Sawicki <dsawicki@google.com> * Copy validation for * from allowMethods to headers This uniformizes the validation for allowMethods and allowHeaders by requiring that when '*' appears in allowHeaders, it must be the only value in the list. Signed-off-by: Damian Sawicki <dsawicki@google.com> * Add section on wildcards to GEP 1767 Signed-off-by: Damian Sawicki <dsawicki@google.com> * Update GEP 1767 metadata with new PR Signed-off-by: Damian Sawicki <dsawicki@google.com> --------- Signed-off-by: Damian Sawicki <dsawicki@google.com>
* add test for cors Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * add more tests Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * Update conformance/tests/httproute-cors.go Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com> * Update conformance/tests/httproute-cors.go Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com> * Add option to ignore whitespace in the resposnse header values Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * support multiple status codes Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * address some comments * Add wildcard test on cors * Add more tests to CORS * Add more CORS conformance tests * address comments on cors tests --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Co-authored-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
What type of PR is this?
/area conformance-test
What this PR does / why we need it:
This PR adds conformance tests for HTTPCORSFilter.
This PR is a fork from #3739 to make CORS promotion possible
Which issue(s) this PR fixes:
Related to #3649
Does this PR introduce a user-facing change?: