| 
53 | 53 |     - [Filter Extension](#filter-extension)  | 
54 | 54 |     - [Query Extension](#query-extension)  | 
55 | 55 |   - [Aggregation](#aggregation)  | 
 | 56 | +  - [Asset Proxy](#asset-proxy)  | 
56 | 57 |   - [Collections and filter parameters for authorization](#collections-and-filter-parameters-for-authorization)  | 
57 | 58 |     - [Collections](#collections)  | 
58 | 59 |     - [CQL2 Filter](#cql2-filter)  | 
@@ -617,6 +618,9 @@ There are some settings that should be reviewed and updated as needeed in the se  | 
617 | 618 | | ENABLE_INGEST_ACTION_TRUNCATE    | Enables support for ingest action "truncate".                                                                                                                                                                                                                                   | none (not enabled)                                                                   |  | 
618 | 619 | | ENABLE_RESPONSE_COMPRESSION      | Enables response compression. Set to 'false' to disable.                                                                                                                                                                                                                        | enabled                                                                              |  | 
619 | 620 | | ITEMS_MAX_LIMIT                  | The maximum limit for the number of items returned from the /search and /collections/{collection_id}/items endpoints. It is recommended that this be set to 100. There is an absolute max limit of 10000 for this.                                                              | 10000                                                                                |  | 
 | 621 | +| ASSET_PROXY_BUCKET_OPTION        | Control which S3 buckets are proxied through the API. Options: `NONE` (disabled), `ALL` (all S3 assets), `ALL_BUCKETS_IN_ACCOUNT` (all buckets in AWS account), `LIST` (specific buckets only).                                                                                 | NONE                                                                                 |  | 
 | 622 | +| ASSET_PROXY_BUCKET_LIST          | Comma-separated list of S3 bucket names to proxy. Required when `ASSET_PROXY_BUCKET_OPTION` is `LIST`.                                                                                                                                                                          |                                                                                      |  | 
 | 623 | +| ASSET_PROXY_URL_EXPIRY           | Pre-signed URL expiry time in seconds for proxied assets.                                                                                                                                                                                                                        | 300                                                                                  |  | 
620 | 624 | 
 
  | 
621 | 625 | Additionally, the credential for OpenSearch must be configured, as decribed in the  | 
622 | 626 | section [Populating and accessing credentials](#populating-and-accessing-credentials).  | 
@@ -1124,6 +1128,144 @@ Available aggregations are:  | 
1124 | 1128 | - geometry_geohash_grid_frequency ([geohash grid](https://opensearch.org/docs/latest/aggregations/bucket/geohash-grid/) on Item.geometry)  | 
1125 | 1129 | - geometry_geotile_grid_frequency ([geotile grid](https://opensearch.org/docs/latest/aggregations/bucket/geotile-grid/) on Item.geometry)  | 
1126 | 1130 | 
 
  | 
 | 1131 | +## Asset Proxy  | 
 | 1132 | + | 
 | 1133 | +The Asset Proxy feature enables stac-server to proxy access to S3 assets through the STAC  | 
 | 1134 | +API by generating pre-signed URLs. Only assets with S3 URIs (`s3://` prefix) are proxied;  | 
 | 1135 | +other URL schemes are ignored. When the Asset Proxy feature is enabled, asset `href`  | 
 | 1136 | +values pointing to S3 are replaced with proxy endpoint URLs when an Item or Collection is  | 
 | 1137 | +served, while the original S3 URLs are preserved in the `alternate.s3.href` field using  | 
 | 1138 | +the [Alternate Assets Extension](https://github.com/stac-extensions/alternate-assets).  | 
 | 1139 | +Subsequent GET requests to the proxy endpoint URLs are redirected to pre-signed S3 URLS  | 
 | 1140 | +for download. Note that the AWS account that stac-server is running under must have  | 
 | 1141 | +permission to access the S3 buckets containing the assets and that the stac-server AWS  | 
 | 1142 | +account will be charged for the S3 egress, regardless of whether the bucket is a  | 
 | 1143 | +"Requester Pays" bucket or not (the stac-server AWS account is the requester when  | 
 | 1144 | +generating the pre-signed URL).  | 
 | 1145 | + | 
 | 1146 | +### Configuration  | 
 | 1147 | + | 
 | 1148 | +Asset proxying uses three environment variables:  | 
 | 1149 | + | 
 | 1150 | +- **`ASSET_PROXY_BUCKET_OPTION` -** Specifies one of four modes to control which S3 buckets are proxied.  | 
 | 1151 | + | 
 | 1152 | +  - **NONE** (default): Asset proxy is disabled. All asset hrefs are returned unchanged.  | 
 | 1153 | +  - **ALL**: Proxy all S3 assets regardless of which bucket they are in.  | 
 | 1154 | +  - **ALL_BUCKETS_IN_ACCOUNT**: Proxy assets from any S3 bucket accessible to the AWS account credentials. The list of buckets is fetched at Lambda startup.  | 
 | 1155 | +  - **LIST**: Only proxy assets from specific buckets listed in `ASSET_PROXY_BUCKET_LIST`.  | 
 | 1156 | + | 
 | 1157 | +- **`ASSET_PROXY_BUCKET_LIST`** — Comma-separated list of bucket names (required only when the `ASSET_PROXY_BUCKET_OPTION` environment variable is set to `LIST`)  | 
 | 1158 | + | 
 | 1159 | +  ```yaml  | 
 | 1160 | +  ASSET_PROXY_BUCKET_OPTION: "LIST"  | 
 | 1161 | +  ASSET_PROXY_BUCKET_LIST: "my-bucket-1,my-bucket-2,my-bucket-3"  | 
 | 1162 | +  ```  | 
 | 1163 | + | 
 | 1164 | +- **`ASSET_PROXY_URL_EXPIRY`** — Pre-signed URL expiry in seconds (default: `300`)  | 
 | 1165 | + | 
 | 1166 | +### Endpoints  | 
 | 1167 | + | 
 | 1168 | +When asset proxying is enabled, two endpoints are available for accessing proxied assets:  | 
 | 1169 | + | 
 | 1170 | +- `GET /collections/{collectionId}/items/{itemId}/assets/{assetKey}` - Redirects (HTTP 302) to a pre-signed S3 URL for an item asset  | 
 | 1171 | +- `GET /collections/{collectionId}/assets/{assetKey}` - Redirects (HTTP 302) to a pre-signed S3 URL for a collection asset  | 
 | 1172 | + | 
 | 1173 | +### IAM Permissions  | 
 | 1174 | + | 
 | 1175 | +For the Asset Proxy feature to generate pre-signed URLs, the API and ingest Lambdas must  | 
 | 1176 | +be assigned permissions for the S3 buckets containing the assets. Add the following to the  | 
 | 1177 | +IAM role statements in your `serverless.yml` file, adjusting the resources as needed:  | 
 | 1178 | + | 
 | 1179 | +For the `LIST` mode, you can specify the buckets listed in `ASSET_PROXY_BUCKET_LIST`:  | 
 | 1180 | + | 
 | 1181 | +```yaml  | 
 | 1182 | +- Effect: Allow  | 
 | 1183 | +  Action:  | 
 | 1184 | +    - s3:GetObject  | 
 | 1185 | +  Resource:  | 
 | 1186 | +    - "arn:aws:s3:::my-bucket-1/*"  | 
 | 1187 | +    - "arn:aws:s3:::my-bucket-2/*"  | 
 | 1188 | +- Effect: Allow  | 
 | 1189 | +  Action:  | 
 | 1190 | +    - s3:HeadBucket  | 
 | 1191 | +    - s3:ListBucket  | 
 | 1192 | +  Resource:  | 
 | 1193 | +    - "arn:aws:s3:::my-bucket-1"  | 
 | 1194 | +    - "arn:aws:s3:::my-bucket-2"  | 
 | 1195 | +```  | 
 | 1196 | + | 
 | 1197 | +For the `ALL` mode, use wildcards:  | 
 | 1198 | + | 
 | 1199 | +```yaml  | 
 | 1200 | +- Effect: Allow  | 
 | 1201 | +  Action:  | 
 | 1202 | +    - s3:GetObject  | 
 | 1203 | +  Resource: "arn:aws:s3:::*/*"  | 
 | 1204 | +- Effect: Allow  | 
 | 1205 | +  Action:  | 
 | 1206 | +    - s3:HeadBucket  | 
 | 1207 | +    - s3:ListBucket  | 
 | 1208 | +  Resource: "arn:aws:s3:::*"  | 
 | 1209 | +```  | 
 | 1210 | + | 
 | 1211 | +When using `ALL_BUCKETS_IN_ACCOUNT` mode, the Lambda also needs permission to list the  | 
 | 1212 | +account buckets:  | 
 | 1213 | + | 
 | 1214 | +```yaml  | 
 | 1215 | +- Effect: Allow  | 
 | 1216 | +  Action:  | 
 | 1217 | +    - s3:GetObject  | 
 | 1218 | +  Resource: "arn:aws:s3:::*/*"  | 
 | 1219 | +- Effect: Allow  | 
 | 1220 | +  Action:  | 
 | 1221 | +    - s3:HeadBucket  | 
 | 1222 | +    - s3:ListBucket  | 
 | 1223 | +  Resource: "arn:aws:s3:::*"  | 
 | 1224 | +- Effect: Allow  | 
 | 1225 | +  Action:  | 
 | 1226 | +    - s3:ListAllMyBuckets  | 
 | 1227 | +  Resource: "*"  | 
 | 1228 | +```  | 
 | 1229 | + | 
 | 1230 | +### Asset Transformation  | 
 | 1231 | + | 
 | 1232 | +When asset proxying is enabled and an asset's `href` points to an S3 URL, the asset is transformed as follows:  | 
 | 1233 | + | 
 | 1234 | +**Original asset:**  | 
 | 1235 | +```json  | 
 | 1236 | +{  | 
 | 1237 | +  "thumbnail": {  | 
 | 1238 | +    "href": "s3://my-bucket/path/to/thumbnail.png",  | 
 | 1239 | +    "type": "image/png",  | 
 | 1240 | +    "roles": ["thumbnail"]  | 
 | 1241 | +  }  | 
 | 1242 | +}  | 
 | 1243 | +```  | 
 | 1244 | + | 
 | 1245 | +**Transformed asset:**  | 
 | 1246 | +```json  | 
 | 1247 | +{  | 
 | 1248 | +  "thumbnail": {  | 
 | 1249 | +    "href": "https://api.example.com/collections/my-collection/items/my-item/assets/thumbnail",  | 
 | 1250 | +    "type": "image/png",  | 
 | 1251 | +    "roles": ["thumbnail"],  | 
 | 1252 | +    "alternate": {  | 
 | 1253 | +      "s3": {  | 
 | 1254 | +        "href": "s3://my-bucket/path/to/thumbnail.png"  | 
 | 1255 | +      }  | 
 | 1256 | +    }  | 
 | 1257 | +  }  | 
 | 1258 | +}  | 
 | 1259 | +```  | 
 | 1260 | + | 
 | 1261 | +The item or collection will also have the Alternate Assets Extension added to its `stac_extensions` array:  | 
 | 1262 | + | 
 | 1263 | +```json  | 
 | 1264 | +"stac_extensions": [  | 
 | 1265 | +  "https://stac-extensions.github.io/alternate-assets/v1.2.0/schema.json"  | 
 | 1266 | +]  | 
 | 1267 | +```  | 
 | 1268 | + | 
1127 | 1269 | ## Collections and filter parameters for authorization  | 
1128 | 1270 | 
 
  | 
1129 | 1271 | One key concern in stac-server is how to restrict user's access to items.  These  | 
@@ -1160,6 +1302,8 @@ The endpoints this applies to are:  | 
1160 | 1302 | - /collections/:collectionId/items  | 
1161 | 1303 | - /collections/:collectionId/items/:itemId  | 
1162 | 1304 | - /collections/:collectionId/items/:itemId/thumbnail  | 
 | 1305 | +- /collections/:collectionId/items/:itemId/assets/:assetKey  | 
 | 1306 | +- /collections/:collectionId/assets/:assetKey  | 
1163 | 1307 | - /search  | 
1164 | 1308 | - /aggregate  | 
1165 | 1309 | 
 
  | 
@@ -1187,6 +1331,8 @@ The endpoints this applies to are:  | 
1187 | 1331 | - /collections/:collectionId/items  | 
1188 | 1332 | - /collections/:collectionId/items/:itemId  | 
1189 | 1333 | - /collections/:collectionId/items/:itemId/thumbnail  | 
 | 1334 | +- /collections/:collectionId/items/:itemId/assets/:assetKey  | 
 | 1335 | +- /collections/:collectionId/assets/:assetKey  | 
1190 | 1336 | - /search  | 
1191 | 1337 | - /aggregate  | 
1192 | 1338 | 
 
  | 
 | 
0 commit comments