You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Overview
- Allow each service to specify values for `Access-Control-Allow-Origin`
Previously, if a `location` block in the `nginx` configuration for a
given service included the cors helper
configuration (with `include /etc/nginx/conf.d/cors.include;`) then all
origins were allowed by default.
This was done by setting the header `Access-Control-Allow-Origin: *`
which works well but is a bit too permissive
since it allowed __all__ origins.
This change introduces a mechanism to specify specific additional
allowed origins by setting the
`$access_control_allow_origin` nginx variable in the `location` block
before including the `cors.include` file.
For example:
```
set $access_control_allow_origin http://example.com;
include /etc/nginx/conf.d/cors.include;
```
will set the value of the `Access-Control-Allow-Origin` response header
to `http://example.com`.
By default, the header value will be `*` if
`$access_control_allow_origin` is not set (to maintain backwards
compatibility).
To specify multiple allowed origins, use a `map` directive (see the
implementation for `components/stac` for an
example).
- Set allowed CORS origins for `stac` through an environment variable
This change implements this flexibility for the `components/stac`
component. By setting the `STAC_CORS_ORIGINS`
variable a user can specify allowed origins for responses from the
`components/stac` component.
For example, setting the following:
```
export STAC_CORS_ORIGINS='https://example.com
~^https?://(www\.)?other\.example\.com$'
```
then requests from https://example.com and http://other.example.com will
get a response with the
`Access-Control-Allow-Origin header` set to their origin, but
http://example.ca will not.
Note that this breaks backwards compatibility slightly since previously
all origins were allowed for `/stac` by
default. To keep the backwards compatible behaviour you can set:
```
export STAC_CORS_ORIGINS='~.*'
```
to match all origins.
## Changes
**Non-breaking changes**
- Adds mechanism to allow services to have more control over CORS
headers
**Breaking changes**
- responses from `/stac` no longer set `Access-Control-Allow-Origin: *`
by default
## Related Issue / Discussion
- As discussed in #450
## Additional Information
## CI Operations
<!--
The test suite can be run using a different DACCS config with
``birdhouse_daccs_configs_branch: branch_name`` in the PR description.
To globally skip the test suite regardless of the commit message use
``birdhouse_skip_ci`` set to ``true`` in the PR description.
Using ``[<cmd>]`` (with the brackets) where ``<cmd> = skip ci`` in the
commit message will override ``birdhouse_skip_ci`` from the PR
description.
Such commit command can be used to override the PR description behavior
for a specific commit update.
However, a commit message cannot 'force run' a PR which the description
turns off the CI.
To run the CI, the PR should instead be updated with a ``true`` value,
and a running message can be posted in following PR comments to trigger
tests once again.
-->
birdhouse_daccs_configs_branch: master
birdhouse_skip_ci: false
0 commit comments