Skip to content

Commit 29975e8

Browse files
authored
Add CQL2 filter parameter for Authorization (#972)
* upgrade dependencies * Add 'hidden' filter parameter/header for arbitrary authx to items
1 parent 62b6525 commit 29975e8

15 files changed

+1090
-169
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased - TBD
9+
10+
## Changed
11+
12+
- If a request includes the `STAC-Endpoint` header, that endpoint will be used when generating link hrefs.
13+
This deprecates (but still supports) the `X-STAC-Endpoint` header. This change is in order to comply
14+
with the proprietary header name recommendations in RFC 6648.
15+
16+
## Added
17+
18+
- To all endpoints that accept a `filter` parameter, add support for a query parameter (GET)
19+
or body field (POST) `_filter` or a header `STAC-Filter-Authx` that will "and" a CQL2
20+
filter expression to the user's
21+
request, such that the extra expression will not be
22+
will not be revealed in link contents. This is controlled by the `ENABLE_FILTER_AUTHX`
23+
environment variable.
24+
- To all endpoints that already support the `_collections` parameter, also support a
25+
header `STAC-Collections-Authx` to pass the value.
26+
827
## [4.3.0] - 2025-07-16
928

1029
### Changed

README.md

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
- [Filter Extension](#filter-extension)
5454
- [Query Extension](#query-extension)
5555
- [Aggregation](#aggregation)
56-
- [Hidden collections filter for authorization](#hidden-collections-filter-for-authorization)
56+
- [Collections and filter parameters for authorization](#collections-and-filter-parameters-for-authorization)
57+
- [Collections](#collections)
58+
- [CQL2 Filter](#cql2-filter)
5759
- [Ingesting Data](#ingesting-data)
5860
- [Ingest actions](#ingest-actions)
5961
- [Ingesting large items](#ingesting-large-items)
@@ -609,7 +611,8 @@ There are some settings that should be reviewed and updated as needeed in the se
609611
| CORS_CREDENTIALS | Configure whether or not to send the `Access-Control-Allow-Credentials` CORS header. Header will be sent if set to `true`. | none |
610612
| CORS_METHODS | Configure whether or not to send the `Access-Control-Allow-Methods` CORS header. Expects a comma-delimited string, e.g., `GET,PUT,POST`. | `GET,HEAD,PUT,PATCH,POST,DELETE` |
611613
| CORS_HEADERS | Configure whether or not to send the `Access-Control-Allow-Headers` CORS header. Expects a comma-delimited string, e.g., `Content-Type,Authorization`. If not specified, defaults to reflecting the headers specified in the request’s `Access-Control-Request-Headers` header. | none |
612-
| ENABLE_COLLECTIONS_AUTHX | Enables support for hidden `_collections` query parameter / field when set to `true`. | none (not enabled) |
614+
| ENABLE_COLLECTIONS_AUTHX | Enables support for parameter to restrict collections when set to `true`. | none (not enabled) |
615+
| ENABLE_FILTER_AUTHX | Enables support for parameter to restrict items when set to `true`. | none (not enabled) |
613616
| ENABLE_THUMBNAILS | Enables support for presigned thumbnails. | none (not enabled) |
614617
| ENABLE_INGEST_ACTION_TRUNCATE | Enables support for ingest action "truncate". | none (not enabled) |
615618
| ENABLE_RESPONSE_COMPRESSION | Enables response compression. Set to 'false' to disable. | enabled |
@@ -618,6 +621,9 @@ There are some settings that should be reviewed and updated as needeed in the se
618621
Additionally, the credential for OpenSearch must be configured, as decribed in the
619622
section [Populating and accessing credentials](#populating-and-accessing-credentials).
620623

624+
If using STAC Server with a proxy in front of it, the base URL for the server, which
625+
will be used in all link URLs in response bodies, can be set with the `STAC-Endpoint` header.
626+
621627
After reviewing the settings, build and deploy:
622628

623629
```shell
@@ -1118,16 +1124,32 @@ Available aggregations are:
11181124
- geometry_geohash_grid_frequency ([geohash grid](https://opensearch.org/docs/latest/aggregations/bucket/geohash-grid/) on Item.geometry)
11191125
- geometry_geotile_grid_frequency ([geotile grid](https://opensearch.org/docs/latest/aggregations/bucket/geotile-grid/) on Item.geometry)
11201126

1121-
## Hidden collections filter for authorization
1127+
## Collections and filter parameters for authorization
11221128

1123-
All endpoints that involve the use of Collections support the use of a "hidden" query
1124-
parameter named (for GET requests) or body JSON field (for POST requests) named
1125-
`_collections` that can be used by an authorization proxy (e.g., a pre-hook Lambda)
1126-
to filter the collections a user has access to. This parameter/field will be excluded
1127-
from pagination links, so it does not need to be removed on egress.
1129+
One key concern in stac-server is how to restrict user's access to items. These
1130+
features allow this introducing support for injecting values at runtime (e.g., in a
1131+
proxy or pre-hook Lambda) to restrict items by collection or by CQL2 filter.
1132+
1133+
### Collections
11281134

11291135
This feature must be enabled with the `ENABLE_COLLECTIONS_AUTHX` configuration.
11301136

1137+
All endpoints that involve the use of Collections support the use of a additional
1138+
parameter that indicates which collections a user should have access to. This parameter
1139+
can be injected as:
1140+
1141+
1. GET request - a query parameter `_collections`
1142+
2. POST request - a body field `_collections`
1143+
3. All requests - an HTTP header `stac-collections-authx`
1144+
1145+
This parameter/field will be excluded
1146+
from pagination links, so it does not need to be removed on egress.
1147+
1148+
If this behavior is enabled and a parameter is not passed or is passed
1149+
with an empty string or empty list, the caller will not have access to any collections.
1150+
When `*` is included in the list of collections (presumably as the only value), the caller
1151+
will have access to all collections.
1152+
11311153
The endpoints this applies to are:
11321154

11331155
- /collections
@@ -1141,13 +1163,35 @@ The endpoints this applies to are:
11411163
- /search
11421164
- /aggregate
11431165

1144-
The five endpoints of the Transaction Extension do not use this parameter, as there are
1166+
The five endpoints of the Transaction Extension do not use these parameters, as there are
11451167
other authorization considerations for these, that are left as future work.
11461168

1147-
If this behavior is enabled and a `_collections` parameter is not passed or is passed
1148-
with an empty string or empty list, the caller will not have access to any collections.
1149-
When `*` is included in the list of collections (ideally as the only value), the caller
1150-
will have access to all collections.
1169+
### CQL2 Filter
1170+
1171+
This feature must be enabled with the `ENABLE_FILTER_AUTHX` configuration.
1172+
1173+
All endpoints that involve items support the use of a additional
1174+
parameter that indicates which items a user should have access to. This parameter
1175+
can be injected as:
1176+
1177+
1. GET request - a query parameter `_filter`
1178+
2. POST request - a body field `_filter`
1179+
3. All requests - an HTTP header `stac-filter-authx`
1180+
1181+
This parameter/field will be excluded
1182+
from pagination links, so it does not need to be removed on egress.
1183+
1184+
The endpoints this applies to are:
1185+
1186+
- /collections/:collectionId/aggregate
1187+
- /collections/:collectionId/items
1188+
- /collections/:collectionId/items/:itemId
1189+
- /collections/:collectionId/items/:itemId/thumbnail
1190+
- /search
1191+
- /aggregate
1192+
1193+
One limitation of the header approach is that API Gateway has a hard limit of 10240 or
1194+
8000 bytes (depending on the type), so a large filter could exceed this.
11511195

11521196
## Ingesting Data
11531197

bin/system-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export REQUEST_LOGGING_ENABLED=false
1212

1313
echo "Running tests"
1414
set +e
15+
16+
# add --match to restrict by test name
1517
npx ava "./tests/system/${TEST_PATTERN}" --serial --verbose
1618
TEST_RESULT="$?"
1719
set -e

package-lock.json

Lines changed: 43 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)