-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(cors): don't send Access-Control-Allow-Origin header where a single origin(not regex) is configured #10898
Conversation
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.
LGTM
4e77aa2
to
cced81e
Compare
configured in case of non-matched. The CORS plugin currently always sets the ACAO header based on the plugin configuration if the configuration only has a single entry and contains only non-PCRE metacharacters. This behavior is first introduced in #2482 and doesn't seem to have any real impact on the functionality I think. But this seems is not following the [mozilla guidelines](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin) > Specifies an origin. Only a single origin can be specified. If the server supports clients from multiple origins, it must return the origin for the specific client making the request. This fixes behavior by no longer sending an ACAO header in this case.
cced81e
to
4a6c032
Compare
I recall putting in a comment but I cannot see it here now. |
I don’t like what we are currently doing, and I don’t like that we are not following the CORS standard. I would have zero concerns about doing this on a major release (4.0). However, CORS is our most used plugin according to our stats. Making changes such as this on a minor release can be very problematic. @ms2008 is it possible to fix the customer issue (missing port) without removing the "smartness" from the plugin? If there is, that would be my preferred way to do this. While we decide this, can we give the customer a workaround? E.g. would it be possible to sidestep this problem by adding a "dummy" domain in the config? To summarize, my proposed solution would be:
|
@kikito I read the RFC and W3C specifications carefully, and I think the behavior of stripping the port part(if it is equal to the default value) is reasonable even though they are explicitly specified in the Origin request header. I have tried to verify this behavior(stripping the default port) on Chrome and have determined if Chrome recognizes this behavior. Unfortunately, Chrome does not allow custom CORS requests for origin at all. I still think this is an issue with the customer's own specific software and should be left up to them to fix(e.g. customize their own CORS plugin), not to change our behavior. |
What does 'freeze' mean in the context of this PR? |
I think the concerns raised by Apao and Enrique are valid. Considering that it seems like a potentially breaking change and doesn't have any substantial impact on functionality, I lean towards closing this PR. |
Summary
The CORS plugin currently always sets the Access-Control-Allow-Origin header based on the plugin configuration if the configuration only has a single entry and contains only non-PCRE metacharacters. This behavior is first introduced in #2482 and doesn't seem to have any real impact on the functionality I think.
But this seems is not following the mozilla guidelines
This fixes behavior by no longer sending an ACAO header in this case.
These changes seem reasonable to me, but happy to hear feedback.
Checklist
Full changelog
Issue reference
Fix FTI-4745