Skip to content

Commit 77ee542

Browse files
Description updates and local tests passed
1 parent c7bd6e4 commit 77ee542

File tree

3 files changed

+70
-54
lines changed

3 files changed

+70
-54
lines changed

.vscode

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"editor.wordWrap": "wordWrapColumn",
3+
"editor.wrappingIndent": "same",
4+
"editor.wordWrapColumn": 150
5+
}

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Updated schema.json
1313

1414
### Changed
15+
- README.md updates
16+
- Updated secure asset item.json and collection.json to handle multiple authentification schemes
17+
- Updated schema.json for the updated security object structure
18+
19+
- Updated README.md descriptions of the library
1520

1621
### Deprecated
1722

README.md

+60-54
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
- **Extension [Maturity Classification](https://github.com/radiantearth/stac-spec/tree/master/extensions/README.md#extension-maturity):** Proposal
88
- **Owner**: @jamesfisher-gis
99

10-
The Secure Assets extension to the [STAC](https://github.com/radiantearth/stac-spec) specification provides a standard way to specify if an asset
11-
resides in secure storage. An alternative method (i.e. presigned URLs) would be required to access these assets. Presigned URL generation would
12-
require calling out to an external API. The aim of the Secure Assets extension is to provide a standard field for clients to recognise secure assets
13-
and access them via the user's preferred method.
10+
The Secure Assets extension to the [STAC](https://github.com/radiantearth/stac-spec) specification provides a way to specify what authentification
11+
scheme is needed to access an asset in secured storage. The aim of the Secure Assets extension is to provide a standard field for clients to
12+
recognise secure assets and access them via the specified authentification scheme.
1413

15-
The Secure Assets extension is similar to the
16-
[Alternative Assets extension](https://github.com/stac-extensions/alternate-assets/tree/main#alternate-asset-object) which aims to specify alternate
17-
locations (e.g., URLs) for assets. Secure Assets aims to specify if an alternative dynamic method (presigned URLs) is needed.
14+
The Secure Assets extension aligns with the [stac-asset](https://github.com/stac-utils/stac-asset) which has support for several
15+
[authentification clients](https://github.com/stac-utils/stac-asset#clients). A `SignedUrlClient` scheme may be specified that uses a custom API to
16+
generate signed URLs. See the [Signed URL](#url-signing) section for an example Lambda function.
1817

1918
- Examples:
2019
- [Item example](examples/item.json): Shows the basic usage of the extension in a STAC Item
@@ -25,47 +24,49 @@ locations (e.g., URLs) for assets. Secure Assets aims to specify if an alternati
2524
## Fields
2625

2726
The fields in the table below can be used in these parts of STAC documents:
27+
2828
- [ ] Catalogs
2929
- [ ] Collections
3030
- [ ] Item Properties (incl. Summaries in Collections)
3131
- [x] Assets (for both Collections and Items, incl. Item Asset Definitions in Collections)
3232
- [ ] Links
3333

34-
| Field Name | Type | Description |
35-
| -------------------- | ------------------------- | ----------- |
36-
| security | Map<string, [SecureAsset Object](#secure-asset-object)> | Object that desribes the authenticated scheme and href |
34+
| Field Name | Type | Description |
35+
| ---------- | ------------------------------------------------------- | ------------------------------------------------------ |
36+
| security | Map<string, [SecureAsset Object](#secure-asset-object)> | Object that desribes the authenticated scheme and href |
3737

3838
### Additional Field Information
3939

4040
#### security
4141

4242
An Asset property used to specify a keyword that defines the security level of the Asset.The most common values may be "private" or "public".
43-
However, other keyword may be used to for alternative methods or levels of security.
43+
However, other keyword may be used to for alternative methods or levels of security.
4444

4545
### Secure Asset Object
4646

4747
An Asset with the Secure Assets extension will have the following fields
4848

49-
| Field Name | Type | Description |
50-
| ----------- | ------ | ----------- |
51-
| scheme | string | **REQUIRED**. The authentification scheme used to access the data (`HttpClient` \| `S3Client` \| `PlanetaryComputerClient` \| `EarthdataClient` \| `SignedUrlClient`). |
52-
| description | string | Additional instructions for authentification |
49+
| Field Name | Type | Description |
50+
| ----------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
51+
| scheme | string | **REQUIRED**. The authentification scheme used to access the data (`HttpClient` \| `S3Client` \| `PlanetaryComputerClient` \| `EarthdataClient` \| `SignedUrlClient`). |
52+
| description | string | Additional instructions for authentification |
5353

5454
### Schemes
5555

5656
The authentification schemes align with the relevant clients included in the [stac-asset](https://github.com/stac-utils/stac-asset) library.
5757

58-
| Name | Description
59-
| -- | -- |
60-
| `HttpClient` | Simple HTTP client without any authentication |
61-
| `S3Client` | Simple S3 client
62-
| `PlanetaryComputerClient` | Signs URLs with the [Planetary Computer Authentication API](https://planetarycomputer.microsoft.com/docs/reference/sas/)
63-
| `EarthdataClient` | Uses a token-based authentication to download data, from _some_ Earthdata providers, e.g. DAACs
64-
| `SignedUrlClient` | Signs URLs with a user-defined Authentification API
58+
| Name | Description |
59+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
60+
| `HttpClient` | Simple HTTP client without any authentication |
61+
| `S3Client` | Simple S3 client |
62+
| `PlanetaryComputerClient` | Signs URLs with the [Planetary Computer Authentication API](https://planetarycomputer.microsoft.com/docs/reference/sas/) |
63+
| `EarthdataClient` | Uses a token-based authentication to download data, from _some_ Earthdata providers, e.g. DAACs |
64+
| `SignedUrlClient` | Signs URLs with a user-defined Authentification API |
6565

6666
### URL Signing
6767

68-
The `SignedUrlClient` scheme indicates that authentification will be handled by an API which generates and returns a signed URL. For example, a signed URL for assets in AWS S3 can be generated with the following Lambda function code.
68+
The `SignedUrlClient` scheme indicates that authentification will be handled by an API which generates and returns a signed URL. For example,
69+
a signed URL for assets in AWS S3 can be generated with the following Lambda function code.
6970

7071
```python
7172
import boto3
@@ -94,7 +95,7 @@ The `SignedUrlClient` scheme indicates that authentification will be handled by
9495
Params = {"Bucket": bucketName, "Key":key},
9596
ExpiresIn = 360
9697
)
97-
98+
9899
return ({
99100
"statusCode": 200,
100101
"body": json.dumps({
@@ -104,7 +105,7 @@ The `SignedUrlClient` scheme indicates that authentification will be handled by
104105
"Access-Control-Allow-Origin": "*",
105106
"Access-Control-Allow-Headers": "*"
106107
}
107-
108+
108109
})
109110
except Exception as e:
110111
return {
@@ -114,41 +115,43 @@ The `SignedUrlClient` scheme indicates that authentification will be handled by
114115
})
115116
}
116117
```
118+
117119
Where the response looks like
118120

119121
```json
120-
{
121-
"signed_url": "https://<bucket>.s3.<region>.amazonaws.com/<key>?AWSAccessKeyId=<aws access key>&Signature=<signature>&x-amz-security-token=<auth token>&Expires=<epoch expiration time>"
122-
}
122+
{
123+
"signed_url": "https://<bucket>.s3.<region>.amazonaws.com/<key>?AWSAccessKeyId=<aws access key>&Signature=<signature>&x-amz-security-token=<auth token>&Expires=<epoch expiration time>"
124+
}
123125
```
124126

125-
The authentication API can be called clientside using an AWS S3 href (`https://<bucket>.s3.<region>.amazonaws.com/<key>`) with the following code snippet.
127+
The authentication API can be called clientside using an AWS S3 href (`https://<bucket>.s3.<region>.amazonaws.com/<key>`) with the following code
128+
snippet.
126129

127130
```javascript
128-
let signed_url
129-
const auth_api = "";
130-
131-
function createSignedRequestBody(href) {
132-
const bucket = href.split(".")[0].split("//")[1];
133-
const key = href.split("/").slice(3).join("/").replace(/\+/g, " ");
134-
return {
135-
method: "POST",
136-
headers: {
137-
Accept: "application/json",
138-
"Content-Type": "application/json",
139-
},
140-
body: JSON.stringify({ bucket: bucket, key: key }),
141-
redirect: "follow",
142-
};
131+
let signed_url;
132+
const auth_api = "";
133+
134+
function createSignedRequestBody(href) {
135+
const bucket = href.split(".")[0].split("//")[1];
136+
const key = href.split("/").slice(3).join("/").replace(/\+/g, " ");
137+
return {
138+
method: "POST",
139+
headers: {
140+
Accept: "application/json",
141+
"Content-Type": "application/json",
142+
},
143+
body: JSON.stringify({ bucket: bucket, key: key }),
144+
redirect: "follow",
143145
};
144-
145-
Promise(
146-
fetch(auth_api, createSignedRequestBody(href))
147-
.then((resp) => resp.json())
148-
.then((respJson) => {
149-
signed_url = respJson.signed_url;
150-
})
151-
);
146+
}
147+
148+
Promise(
149+
fetch(auth_api, createSignedRequestBody(href))
150+
.then((resp) => resp.json())
151+
.then((respJson) => {
152+
signed_url = respJson.signed_url;
153+
})
154+
);
152155
```
153156

154157
## Contributing
@@ -161,23 +164,26 @@ for running tests are copied here for convenience.
161164

162165
### Running tests
163166

164-
The same checks that run as checks on PR's are part of the repository and can be run locally to verify that changes are valid.
167+
The same checks that run as checks on PR's are part of the repository and can be run locally to verify that changes are valid.
165168
To run tests locally, you'll need `npm`, which is a standard part of any [node.js installation](https://nodejs.org/en/download/).
166169

167-
First you'll need to install everything with npm once. Just navigate to the root of this repository and on
170+
First you'll need to install everything with npm once. Just navigate to the root of this repository and on
168171
your command line run:
172+
169173
```bash
170174
npm install
171175
```
172176

173177
Then to check markdown formatting and test the examples against the JSON schema, you can run:
178+
174179
```bash
175180
npm test
176181
```
177182

178183
This will spit out the same texts that you see online, and you can then go and fix your markdown or examples.
179184

180185
If the tests reveal formatting problems with the examples, you can fix them with:
186+
181187
```bash
182188
npm run format-examples
183189
```

0 commit comments

Comments
 (0)