Skip to content

Commit 8592546

Browse files
author
Phil Varner
authored
Merge branch 'main' into pv/enable-typescript-take-two
2 parents e0ac59f + a54a9cc commit 8592546

File tree

5 files changed

+67
-62
lines changed

5 files changed

+67
-62
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ 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+
## [0.5.1] - 2023-01-10
9+
10+
### Changed
11+
12+
- Max size for POST body is now 1mb instead of 100kb.
13+
814
## [0.5.0] - 2022-12-23
915

1016
### Removed

README.md

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ the OpenSearch domain into it.
166166
With the 0.4.x codebase, change the serverless.yml file to add to the AWS::Elasticsearch::Domain definition at the same
167167
level as the `Type` attribute these two attributes:
168168

169-
```
169+
```yaml
170170
DeletionPolicy: Retain
171171
UpdateReplacePolicy: Retain
172172
```
@@ -282,7 +282,7 @@ validate that `properties.datetime` type is `date`, and `id` and `collection` ma
282282

283283
The results should look simliar to this:
284284

285-
```
285+
```json
286286
{
287287
"my_collection_name": {
288288
"mappings": {
@@ -413,7 +413,7 @@ There are some settings that should be reviewed and updated as needeed in the se
413413
| OPENSEARCH_USERNAME | The username to authenticate to OpenSearch with if fine-grained access control is enabled. | |
414414
| OPENSEARCH_PASSWORD | The password to authenticate to OpenSearch with if fine-grained access control is enabled. | |
415415
| OPENSEARCH_CREDENTIALS_SECRET_ID | The AWS Secrets Manager secret to retrieve the username and password from, to authenticate to OpenSearch with if fine-grained access control is enabled. | |
416-
| COLLECTION_TO_INDEX_MAPPINGS | A JSON object representing collection id to index name mappings if they do not have the same names. | |
416+
| COLLECTION_TO_INDEX_MAPPINGS | A JSON object representing collection id to index name mappings if they do not have the same names. | |
417417

418418
| ITEMS_INDICIES_NUM_OF_SHARDS | Configure the number of shards for the indices that contain Items. | none |
419419
| ITEMS_INDICIES_NUM_OF_REPLICAS | Configure the number of replicas for the indices that contain Items. | none |
@@ -528,25 +528,25 @@ to the Elasticsearch -> OpenSearch migration process.
528528
Add this to the `AWS::OpenSearchService::Domain` resource:
529529

530530
```yaml
531-
DomainEndpointOptions:
532-
EnforceHTTPS: true
533-
NodeToNodeEncryptionOptions:
534-
Enabled: true
535-
EncryptionAtRestOptions:
536-
Enabled: true
537-
AdvancedSecurityOptions:
538-
Enabled: true
539-
InternalUserDatabaseEnabled: true
540-
MasterUserOptions:
541-
MasterUserName: admin
542-
MasterUserPassword: ${env:OPENSEARCH_MASTER_USER_PASSWORD}
543-
AccessPolicies:
544-
Version: "2012-10-17"
545-
Statement:
546-
- Effect: "Allow"
547-
Principal: { "AWS": "*" }
548-
Action: "es:ESHttp*"
549-
Resource: "arn:aws:es:arn:aws:es:${aws:region}:${aws:accountId}:domain/${self:service}-${self:provider.stage}/*"
531+
DomainEndpointOptions:
532+
EnforceHTTPS: true
533+
NodeToNodeEncryptionOptions:
534+
Enabled: true
535+
EncryptionAtRestOptions:
536+
Enabled: true
537+
AdvancedSecurityOptions:
538+
Enabled: true
539+
InternalUserDatabaseEnabled: true
540+
MasterUserOptions:
541+
MasterUserName: admin
542+
MasterUserPassword: ${env:OPENSEARCH_MASTER_USER_PASSWORD}
543+
AccessPolicies:
544+
Version: "2012-10-17"
545+
Statement:
546+
- Effect: "Allow"
547+
Principal: { "AWS": "*" }
548+
Action: "es:ESHttp*"
549+
Resource: "arn:aws:es:${aws:region}:${aws:accountId}:domain/${self:service}-${self:provider.stage}/*"
550550
```
551551

552552
The AccessPolicies Statement will restrict the OpenSearch instance to only being accessible
@@ -572,8 +572,7 @@ This assumes the master username is `admin` and creats a user with the name `sta
572572

573573
Create the Role:
574574

575-
```
576-
## Request (2) Duplicate
575+
```shell
577576
curl -X "PUT" "${HOST}/_plugins/_security/api/roles/stac_server_role" \
578577
-H 'Content-Type: application/json; charset=utf-8' \
579578
-u 'admin:xxxxxxxx' \
@@ -608,7 +607,7 @@ curl -X "PUT" "${HOST}/_plugins/_security/api/roles/stac_server_role" \
608607

609608
Create the User:
610609

611-
```
610+
```shell
612611
curl -X "PUT" "${HOST}/_plugins/_security/api/internalusers/stac_server" \
613612
-H 'Content-Type: application/json; charset=utf-8' \
614613
-u 'admin:xxxxxxxx' \
@@ -619,7 +618,7 @@ Double-check the response to ensure that the user was actually created!
619618

620619
Map the Role to the User:
621620

622-
```
621+
```shell
623622
curl -X "PUT" "${HOST}/_plugins/_security/api/rolesmapping/stac_server_role" \
624623
-H 'Content-Type: application/json; charset=utf-8' \
625624
-u 'admin:xxxxxxxx' \
@@ -669,7 +668,7 @@ values, e.g., `stac_server` and whatever you set as the password when creating t
669668
Add the `OPENSEARCH_CREDENTIALS_SECRET_ID` variable to the serverless.yml section
670669
`environment`:
671670

672-
```
671+
```yaml
673672
OPENSEARCH_CREDENTIALS_SECRET_ID: ${self:provider.stage}/${self:service}/opensearch
674673
```
675674

@@ -741,7 +740,7 @@ def lambda_handler(event, context):
741740

742741
If you wanted to deploy STAC Server in a way which ensures certain endpoints have restricted access but others don't, you can deploy it into a VPC and add conditions that allow only certain IP addresses to access certain endpoints. Once you deploy STAC Server into a VPC, you can modify the Resource Policy of the API Gateway endpoint that gets deployed to restrict access to certain endpoints. Here is a hypothetical example. Assume that the account into which STAC Server is deployed is numbered 1234-5678-9123, the API ID is ab1c23def, and the region in which it is deployed is us-west-2. You might want to give the general public access to use any GET or POST endpoints with the API such as the "/search" endpoint, but lock down access to the transaction endpoints (see <https://github.com/radiantearth/stac-api-spec/tree/master/ogcapi-features/extensions/transaction>) to only allow certain IP addresses to access them. These IP addresses can be, for example: 94.61.192.106, 204.176.50.129, and 11.27.65.78. In order to do this, you can impose a condition on the API Gateway that only allows API transactions such as adding, updating, and deleting STAC items from the whitelisted endpoints. For example, here is a Resource Policy containing two statements that allow this to happen:
743742

744-
```
743+
```json
745744
{
746745
"Version": "2012-10-17",
747746
"Statement": [
@@ -782,27 +781,27 @@ If you wanted to deploy STAC Server in a way which ensures certain endpoints hav
782781

783782
The first statement in the Resource Policy above grants access to STAC API endpoints for use in general operations like searching, and the second statement restricts access to the Transaction endpoints to a set of source IP addresses. According to this policy, POST, PUT, PATCH, and DELETE operations on items within collections are only allowed if the request originates from the IP addresses 94.61.192.106, 204.176.50.129, or 11.27.65.78. The second statement can also be written in another manner, denying access to the Transaction endpoints for all addresses that don’t match a set of source IP addresses. This is shown below.
784783

785-
```
786-
{
787-
"Effect": "Deny",
788-
"Principal": "*",
789-
"Action": "execute-api:Invoke",
790-
"Resource": [
791-
"arn:aws:execute-api:us-west-2:123456789123:ab1c23def/v1/POST/collections/*/items",
792-
"arn:aws:execute-api:us-west-2:123456789123:ab1c23def/v1/PUT/collections/*/items/*",
793-
"arn:aws:execute-api:us-west-2:123456789123:ab1c23def/v1/PATCH/collections/*/items/*",
794-
"arn:aws:execute-api:us-west-2:123456789123:ab1c23def/v1/DELETE/collections/*/items/*"
795-
],
796-
"Condition": {
797-
"NotIpAddress": {
798-
"aws:sourceIp": [
799-
"94.61.192.106",
800-
"204.176.50.129",
801-
"11.27.65.78"
802-
]
803-
}
784+
```json
785+
{
786+
"Effect": "Deny",
787+
"Principal": "*",
788+
"Action": "execute-api:Invoke",
789+
"Resource": [
790+
"arn:aws:execute-api:us-west-2:123456789123:ab1c23def/v1/POST/collections/*/items",
791+
"arn:aws:execute-api:us-west-2:123456789123:ab1c23def/v1/PUT/collections/*/items/*",
792+
"arn:aws:execute-api:us-west-2:123456789123:ab1c23def/v1/PATCH/collections/*/items/*",
793+
"arn:aws:execute-api:us-west-2:123456789123:ab1c23def/v1/DELETE/collections/*/items/*"
794+
],
795+
"Condition": {
796+
"NotIpAddress": {
797+
"aws:sourceIp": [
798+
"94.61.192.106",
799+
"204.176.50.129",
800+
"11.27.65.78"
801+
]
804802
}
805803
}
804+
}
806805
```
807806

808807
### AWS WAF Rule Conflicts
@@ -811,7 +810,7 @@ Frequently, stac-server is deployed with AWS WAF protection. When making a POST
811810
that only has the `limit` parameter in the body, a WAF SQL injection protection rule
812811
incurs a false positive and returns a Forbidden status code. This request is an example:
813812

814-
```
813+
```shell
815814
curl -X POST ${HOST}/search -d '{"limit": 1}'
816815
```
817816

@@ -858,15 +857,15 @@ across the clusters, treating a remote cluster as if it were another group of no
858857
cluster, or configure indicies to be replicated (continuously copied) from from one
859858
cluster to another.
860859

861-
Configuring either cross-cluster behavior requires [enabling fine-grained access control](#enable-fine-grained-access-control).
860+
Configuring either cross-cluster behavior requires [enabling fine-grained access control](#enable-opensearch-fine-grained-access-control).
862861

863862
### Cross-cluster Search
864863

865864
The AWS documentation for cross-cluster search can be found
866865
[here](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/cross-cluster-search.html).
867866

868-
1. [Enable fine-grained access control](#enable-fine-grained-access-control)
869-
3. Create a connection between the source and destination OpenSearch domains.
867+
1. [Enable fine-grained access control](#enable-opensearch-fine-grained-access-control)
868+
2. Create a connection between the source and destination OpenSearch domains.
870869
3. Ensure there is a `es:ESCrossClusterGet` action in the destination's access policy.
871870
4. In the source stac-server, create a Collection for each collection to be mapped. This
872871
must have the same id as the destination collection.
@@ -880,9 +879,9 @@ The AWS documentation for cross-cluster search can be found
880879
The AWS documentation for cross-cluster replication can be found
881880
[here](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/replication.html).
882881

883-
1. [Enable fine-grained access control](#enable-fine-grained-access-control)
884-
1. Create the replication connection in the source to the destination
885-
2. Create the collection in the source's stac-server instance
882+
1. [Enable fine-grained access control](#enable-opensearch-fine-grained-access-control)
883+
2. Create the replication connection in the source to the destination
884+
3. Create the collection in the source's stac-server instance
886885

887886
## Pre- and Post-Hooks
888887

@@ -960,7 +959,7 @@ The outputs of the pre- and post-hooks are validated and, if they don't comply w
960959

961960
Install [NVM](https://github.com/nvm-sh/nvm) to manage your Node.js environment.
962961

963-
```
962+
```shell
964963
# uses version in .nvmrc
965964
nvm install
966965
nvm use
@@ -970,7 +969,7 @@ The package-lock.json was built with npm 8.5.0, so use at least this version.
970969

971970
There are several useful npm commands available to use locally:
972971

973-
```
972+
```shell
974973
# Install dependencies in package.json
975974
npm install
976975
@@ -1005,7 +1004,7 @@ Connect to the server on <http://localhost:3000/>
10051004

10061005
Other configurations can be passed as shell environment variables, e.g.,
10071006

1008-
```
1007+
```shell
10091008
export ENABLE_TRANSACTIONS_EXTENSION=true
10101009
export OPENSEARCH_HOST='https://search-stac-server-dev-7awl6h344qlpvly.us-west-2.es.amazonaws.com'
10111010
npm run serve
@@ -1093,7 +1092,7 @@ Next, edit that file to make it specific to this server. For example:
10931092

10941093
To validate the resulting OpenAPI file, run
10951094

1096-
```
1095+
```shell
10971096
npm run check-openapi
10981097
```
10991098

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"displayName": "stac-server",
33
"description": "A STAC API running on stac-server",
4-
"version": "0.4.1",
4+
"version": "0.5.1",
55
"repository": "https://github.com/stac-utils/stac-server",
66
"author": "Alireza Jazayeri, Matthew Hanson <matt.a.hanson@gmail.com>, Sean Harkins",
77
"license": "MIT",

src/lambdas/api/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const app = express()
2323

2424
app.use(logger('dev'))
2525
app.use(cors())
26-
app.use(express.json())
26+
app.use(express.json({ limit: '1mb' }))
2727
app.use(addEndpoint)
2828

2929
app.get('/', async (req, res, next) => {

0 commit comments

Comments
 (0)