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

cors: do not forwarded preflight request if the origin is not allowed #50452

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

zirain
Copy link
Member

@zirain zirain commented Apr 13, 2024

Please provide a description of this PR:

API: istio/api#3171

Related to envoyproxy/envoy#33051

@zirain zirain requested a review from a team as a code owner April 13, 2024 08:09
@istio-testing istio-testing added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 13, 2024
@ramaraochavali
Copy link
Contributor

IMO, we should not introduce a behavioural change unless it is a bug fix, at the very least we should have a feature flag or introduce the flag in the api

@zirain
Copy link
Member Author

zirain commented Apr 13, 2024

IMO, we should not introduce a behavioural change unless it is a bug fix, at the very least we should have a feature flag or introduce the flag in the api

I'm asking what's the best choice, feature flag or api change, or let it be?

@howardjohn
Copy link
Member

Do we have a motivation for this from users? It seems like (without more context) Envoy made a change and we are just copying it without an user demand?

@zirain
Copy link
Member Author

zirain commented Apr 15, 2024

this is a request from our customer, we fixed it in our fork, and want to backport to upstream.

@hzxuzhonghu
Copy link
Member

We cannot simply set it for older proxy

@zirain
Copy link
Member Author

zirain commented Apr 16, 2024

We cannot simply set it for older proxy

if a new pilot feature flag acceptable?

@hzxuzhonghu
Copy link
Member

The correct behavior should be not forwarding non matching preflights. Here we should add a check for proxy version, and only set this field for 1.22?

@zirain zirain changed the title cors: do not forwarded to the upstream if the origin is not allowed cors: do not modify response headers for requests not matching origin Apr 17, 2024
@istio-testing istio-testing added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 17, 2024
Copy link
Member

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does the envoy side talk about "forwarding" but the PR talks about modifying response headers?

@howardjohn
Copy link
Member

But generally if we are making a breaking change compatibilityVersion is the way to do it. But we need agreement that we want to break the behavior for all users

@howardjohn
Copy link
Member

Is there prior art in other gateway implementations?

@zirain zirain changed the title cors: do not modify response headers for requests not matching origin cors: return local reply when preflight origin does not match allowed origins Apr 17, 2024
@zirain zirain changed the title cors: return local reply when preflight origin does not match allowed origins cors: do not forwarded preflight request if the origin is not allowed Apr 17, 2024
@zirain
Copy link
Member Author

zirain commented Apr 17, 2024

why does the envoy side talk about "forwarding" but the PR talks about modifying response headers?

miss with other stuffs

But generally if we are making a breaking change compatibilityVersion is the way to do it. But we need agreement that we want to break the behavior for all users

compatibilityVersion is good to me, or a pilot feature flag?

Is there prior art in other gateway implementations?

this's a new API, AFAIK only EnvoyGateway change it.

@howardjohn
Copy link
Member

I don't mean in Envoy I mean in the broader ecosystem of Cors. So far looks like Kong makes it configurable

@zirain
Copy link
Member Author

zirain commented Apr 17, 2024

I don't mean in Envoy I mean in the broader ecosystem of Cors. So far looks like Kong makes it configurable

After some investigation, nginx base proxy make it configurable, didn't find too much info about HAProxy.

@zirain
Copy link
Member Author

zirain commented Apr 18, 2024

@howardjohn @ramaraochavali @hzxuzhonghu do you agree with use feature flag for this?

@hzxuzhonghu
Copy link
Member

I am ok

@ramaraochavali
Copy link
Contributor

I am also OK as long as we have path forward to remove this via a proper API/making it default behaviour. If our long term plan is API, should we just go ahead with API now? What do you plan to set the default value to be?

@howardjohn
Copy link
Member

My 2c:

  • If we are going to make it an API, do it now
  • If we are going to change the default (1) get agreement on this since its a major behavioral change (2) make an env var, on by default, with compatibility version off by default
  • If we are never going to make it on by default, do not merge anything. Users can use EnvoyFilter.

@zirain
Copy link
Member Author

zirain commented Apr 19, 2024

Personally, I tend to take ForwardNotMatchingPreflights=false as the default behavior.
But for projects that have been around for a long time, changing the default behavior is an unfriendly thing to do, some users may even rely on current behavior, and request to keep the feature flag(pilot env) exists alway.

As all these trade off, is a API change acceptable? If so, I will do that after 1.22 branch cutted.

@ramaraochavali
Copy link
Contributor

My preference would be API and doing it now (without feature flag after 1.22 branch cut)

@zirain zirain requested review from costinm and linsun as code owners May 9, 2024 22:29
@istio-testing istio-testing added needs-rebase Indicates a PR needs to be rebased before being merged and removed needs-rebase Indicates a PR needs to be rebased before being merged labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants