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: Enable multiple Origins value based on regexp. #1251

Merged
merged 1 commit into from
Jan 29, 2021

Conversation

eloycoto
Copy link
Contributor

This will check if the allow_origins is a valid regexp, and if it is,
will match with the Origin header value, it'll set the
Access-Control-Allow-Origin header to the Origin value.

Examples:

Config             | Origin Request Header Value  | Access-Control-Allow-Origin header
(api|web).test.com | http://web.test.com          | http://web.test.com
(api|web).test.com | http://api.test.com          | http://api.test.com
(api|web).test.com | http://staging.test.com      | Not header set
http://test.com    | http://api.test.com          | http://test.com
*                  | http://api.test.com          | *
blank              | http://api.test.com          | http://api.test.com

Fix: THREESCALE-6569

Signed-off-by: Eloy Coto eloy.coto@acalustra.com

@eloycoto eloycoto requested a review from a team as a code owner January 13, 2021 16:01
@@ -46,7 +46,7 @@
}
},
"allow_origin": {
"description": "Origin allowed for CORS requests. The field expects only one origin (e.g. https://example.com) or '*'. If left blank, the value of the 'Origin' request header will be used. In case of valid regexp, and if it matches with Origin header value, the value will be set to the Origin Value. In case of does not match, the header will not set at all.",
"description": "Origin allowed for CORS requests. The field expects only one origin (e.g. <code>https://example.com</code>) or '*'. If left blank, the value of the 'Origin' request header will be used. <br> In order to allow more than one origin it is possible to use a regular expression, if it matches with Origin header value, the value will be set to the Origin Value. In case it does not match, the header will not set at all. Example: <code>(api|web).test.com</code> wil match both <code>api.test.com</code> and <code>web.test.com</code>",

Choose a reason for hiding this comment

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

It seems like GH picked the first suggestion instead of the second (corrected without html markup) :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed now! Thanks!

@eloycoto eloycoto force-pushed the CORS_changes branch 2 times, most recently from 02d21ff to ba678fa Compare January 19, 2021 11:50
Copy link

@damianpm damianpm left a comment

Choose a reason for hiding this comment

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

LGTM

This will check if the allow_origins is a valid regexp, and if it is,
will match with the Origin header value, it'll set the
Access-Control-Allow-Origin header to the Origin value.

Examples:
```
Config             | Origin Request Header Value  | Access-Control-Allow-Origin header
(api|web).test.com | http://web.test.com          | http://web.test.com
(api|web).test.com | http://api.test.com          | http://api.test.com
(api|web).test.com | http://staging.test.com      | Not header set
http://test.com    | http://api.test.com          | http://test.com
*                  | http://api.test.com          | *
blank              | http://api.test.com          | http://api.test.com
```

Fix: THREESCALE-6569

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
@eloycoto eloycoto merged commit 2ae88d8 into 3scale:master Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants