gateway
gateway copied to clipboard
feat(translator): add regex origins for CORS
What this PR does / why we need it:
I've added new field to CORS struct to get ability set flexible regexes to CORSes, because current situation allow only prefix wildcard. So in case of:
- "tld\\.domain(?:\\..*)?"
- ".*:\\/\\/localhost(?:\\:\\d+)?"
- "http:\\/\\/((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}:30\\d\\d"
- null
like mobile app origins or when there is no origing (null) it is impossible to set CORS.
Second point why I did new field is to have back compatibility with existent configuration.
like mobile app origins or when there is no origing (null) it is impossible to set CORS.
@Demacr Thanks for the PR. Could you please provide more details on this? It would be helpful if you could include a real-world example where wildcard match isn't sufficient, but regex works. Thanks.
@zhaohuabing I've mentioned rules, which cannot be matched by prefixed wildcard, in the PR message:
- 1st is our origin from mobile applications, it should have suffixed wildcard
- 2nd could be replaced by
Originstruct validated regex - 3rd one is really rare, but impossible to change by regex which can pass
Originstruct validator - 4th
nullorigin uses our custom Figma's plugin, which call our API with such origin.
Finally, looks like it's possible to add just suffixed wildcard and to add posibility make schemaless origin. Excepting IPs.
@zhaohuabing I've mentioned rules, which cannot be matched by prefixed wildcard, in the PR message:
- 1st is our origin from mobile applications, it should have suffixed wildcard
- 2nd could be replaced by
Originstruct validated regex- 3rd one is really rare, but impossible to change by regex which can pass
Originstruct validator- 4th
nullorigin uses our custom Figma's plugin, which call our API with such origin.Finally, looks like it's possible to add just suffixed wildcard and to add posibility make schemaless origin. Excepting IPs.
Thanks! I think this request is fair enough. LGTM, and defer to other @envoyproxy/gateway-maintainers for any suggestions on the API change.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 67.39%. Comparing base (
0b52320) to head (362fc7e). Report is 1084 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #3928 +/- ##
==========================================
- Coverage 67.42% 67.39% -0.03%
==========================================
Files 183 183
Lines 22443 22447 +4
==========================================
- Hits 15133 15129 -4
- Misses 6224 6228 +4
- Partials 1086 1090 +4
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
hey @Demacr still plan on working on this one ?
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!
closing this PR since its become inactive, feel free to reopen if you're still working on it