stac#
Provider-specific STAC asset signers for EO cloud providers. They implement
pyramids' Signer protocol, so they pass straight into
pyramids.from_stac(signer=…) / pyramids.open_client(signer=…). See the
STAC provider signers guide for per-provider usage.
Signers#
pyramids_eo.stac.signers
#
Provider-specific STAC asset signers for EO cloud providers.
pyramids ships the generic signers (AnonymousSigner,
AWSRequesterPaysSigner, BearerTokenSigner) and the generic Signer
protocol; pyramids-eo owns the provider signers, which encode the semantics
of a specific Earth-observation provider's auth (a hardcoded token endpoint,
a provider-specific URL carve-out) and so are out of scope for a generic GIS
library but squarely in scope for the EO layer (serapeum-org/pyramids-eo#2):
PlanetaryComputerSigner— Microsoft Planetary Computer. Mints a per-(account, container) SAS token over stdliburlliband appends it to the blob href — noplanetary-computerSDK required.EarthdataSigner— NASA Earthdata (EDL). Mints / uses a bearer token from the EDLfind_or_create_tokenendpoint, sent as a GDALAuthorization: Bearerheader for/vsicurl/reads of EDL-gated DAAC assets.CDSESigner— Copernicus Data Space (CDSE) Keycloak-OAuth2 bearer signer for the CDSE HTTPS/OData path (password + refresh grant).CdseS3Signer— Copernicus Data Space, the S3-credential variant: CDSE STAC assets resolve to an S3-compatible store ateodata.dataspace.copernicus.euread with S3 access-key/secret credentials, so this signer is a GDAL-env S3 signer (shaped likeAWSRequesterPaysSigner), not a bearer signer — a different mechanism fromCDSESigner, so both coexist.BdcTokenSigner— Brazil Data Cube (BDC). Rewrites the asset href to carry an?access_token=…query parameter; the token is read from$BDC_ACCESS_TOKEN. Used by the token-gated BDC tiers (rare — most BDC collections in the published STAC v1 catalog read anonymously).
Search is anonymous on these providers (sign_request is a no-op); only the
asset-read boundary needs credentials. The build_signer factory maps a catalog
signer: string to the right object: the anonymous case is the
pyramids-eo-local _AnonymousS3Signer (which adds AWS_NO_SIGN_REQUEST and
region pinning), while aws-requester-pays reuses the pyramids generic signer.
The name -> object mapping lives in one place, the _SIGNER_FACTORIES registry:
build_signer dispatches through it and derives its rejection message from it,
and available_signers publishes its keys so a consumer can validate a catalog
signer: value at parse time. Adding a provider means adding one entry there.
PlanetaryComputerSigner
#
Bases: _BaseSigner
Native Microsoft Planetary Computer SAS signer (no SDK dependency).
PC hosts Sentinel / Landsat / many collections behind short-lived Shared
Access Signature (SAS) tokens. This signer mints a token per
(account, container) from the PC token endpoint and appends it to the
blob href's query string — the same algorithm as planetary_computer.sign
but implemented over the standard library (urllib), so pyramids-eo gains PC
support without taking the planetary-computer SDK as a dependency.
Because the credential rides the URL, gdal_env is empty: a signed
https://<account>.blob.core.windows.net/...?<sas> href is read directly
through GDAL /vsicurl/ with no extra config. Wire it in via
open_client(..., signer=PlanetaryComputerSigner()) (its sign_item
rewrites returned Items) or from_stac(..., signer=PlanetaryComputerSigner()).
Non-PC hrefs, the public ai4edatasetspublicassets bucket, and
already-signed URLs pass through unchanged. Tokens are cached until
refresh_window seconds before their advertised expiry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sas_url
|
str | None
|
SAS token endpoint. Defaults to |
None
|
subscription_key
|
str | None
|
Optional PC subscription key (raises rate limits),
sent as the |
None
|
refresh_window
|
float
|
Refetch a cached token when it is within this many seconds of expiry (default 60). |
60.0
|
timeout
|
float
|
Per-request timeout, in seconds, for the token GET. |
30.0
|
Examples:
- A non-PC href passes through untouched:
- An already-signed blob href is left as-is:
- The public assets bucket is never signed:
Source code in src/pyramids_eo/stac/signers.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
__init__(*, sas_url=None, subscription_key=None, refresh_window=60.0, timeout=30.0)
#
Store endpoint / auth settings and initialise the token cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sas_url
|
str | None
|
SAS token endpoint (env |
None
|
subscription_key
|
str | None
|
Optional PC subscription key (env
|
None
|
refresh_window
|
float
|
Seconds-before-expiry at which a cached token is refetched. |
60.0
|
timeout
|
float
|
Token-request timeout in seconds. |
30.0
|
Source code in src/pyramids_eo/stac/signers.py
sign_href(href)
#
Append a SAS token to a PC blob href; pass non-PC hrefs through.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
href
|
str
|
The asset href. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The href with |
str
|
blob URL, otherwise |
Source code in src/pyramids_eo/stac/signers.py
sign_item(item)
#
Rewrite every asset href on an Item / ItemCollection in place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Any
|
A STAC Item, an ItemCollection (iterable of Items), or the raw-dict equivalent. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None (pystac-client's |
Source code in src/pyramids_eo/stac/signers.py
EarthdataSigner
#
Bases: _BearerProviderSigner
NASA Earthdata (EDL) bearer signer — native, no earthaccess SDK.
Uses a pre-minted token when given (or $EARTHDATA_TOKEN / $EARTHDATA_PAT),
otherwise mints one from the EDL find_or_create_token endpoint with HTTP
Basic auth ($EARTHDATA_USERNAME / $EARTHDATA_PASSWORD). The token is sent
as a GDAL Authorization: Bearer header for /vsicurl/ reads of EDL-gated
DAAC assets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str | None
|
EDL username (env |
None
|
password
|
str | None
|
EDL password (env |
None
|
token
|
str | None
|
A pre-minted bearer token (env |
None
|
refresh_window
|
float
|
Seconds-before-expiry at which to refetch a minted token. |
300.0
|
timeout
|
float
|
Token-request timeout in seconds. |
30.0
|
Examples:
- A pre-minted token is used directly in the GDAL header:
Source code in src/pyramids_eo/stac/signers.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
__init__(*, username=None, password=None, token=None, refresh_window=300.0, timeout=30.0)
#
Store EDL credentials / static token; init the token cache.
Source code in src/pyramids_eo/stac/signers.py
CDSESigner
#
Bases: _BearerProviderSigner
Copernicus Data Space Ecosystem (CDSE) bearer signer via Keycloak OAuth2.
Mints an access token from the CDSE Keycloak token endpoint with a password
grant ($CDSE_USERNAME / $CDSE_PASSWORD, public client cdse-public), then
refreshes it with the refresh-token grant. The access token is sent as a GDAL
Authorization: Bearer header for /vsicurl/ reads of CDSE HTTPS/OData
assets.
This is the bearer (HTTPS/OData) variant; for the S3-credential variant of
CDSE asset reads use CdseS3Signer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str | None
|
CDSE username (env |
None
|
password
|
str | None
|
CDSE password (env |
None
|
client_id
|
str
|
Keycloak client id (default |
'cdse-public'
|
refresh_window
|
float
|
Seconds-before-expiry at which to refresh (CDSE access tokens live ~600 s). |
30.0
|
timeout
|
float
|
Token-request timeout in seconds. |
30.0
|
Source code in src/pyramids_eo/stac/signers.py
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
__init__(*, username=None, password=None, client_id='cdse-public', refresh_window=30.0, timeout=30.0)
#
Store CDSE credentials; init the token + refresh-token cache.
Source code in src/pyramids_eo/stac/signers.py
CdseS3Signer
#
Copernicus Data Space (CDSE) signer (S3 GDAL-env credentials).
CDSE STAC assets live on an S3-compatible store; reads are authenticated
with S3 access-key/secret credentials supplied through the GDAL
environment, and s3://eodata/<key> hrefs are rewritten to the
/vsis3/eodata/<key> GDAL VSI path. Search is anonymous.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
Stable signer label ( |
Examples:
- An
s3://eodata/...href is rewritten to the GDAL/vsis3/path: - An
https://href on the CDSE host is rewritten the same way: - The credentials surface through the GDAL S3 environment:
Source code in src/pyramids_eo/stac/signers.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | |
__init__(access_key, secret_key, endpoint='eodata.dataspace.copernicus.eu')
#
Store the S3 credentials and endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_key
|
str
|
CDSE S3 access key id. |
required |
secret_key
|
str
|
CDSE S3 secret key. |
required |
endpoint
|
str
|
S3 endpoint host. Defaults to the CDSE eodata store. |
'eodata.dataspace.copernicus.eu'
|
Source code in src/pyramids_eo/stac/signers.py
sign_href(href)
#
Rewrite a CDSE asset href to the /vsis3/eodata/<key> GDAL path.
CDSE items expose assets both as s3://eodata/<key> and as
https://<eodata-host>/<key> (the latter is the common default href,
with the s3:// form often only an alternate). Either is rewritten to
the S3 VSI path so the credentials in gdal_env() apply; any other host
is returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
href
|
str
|
An asset href ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The GDAL-readable |
str
|
not a CDSE asset. |
Source code in src/pyramids_eo/stac/signers.py
gdal_env()
#
Return the GDAL config carrying the CDSE S3 credentials for asset reads.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A mapping with the S3 endpoint, access-key/secret, virtual-hosting |
dict[str, str]
|
off, HTTPS on, and the standard cloud-read knob. |
Source code in src/pyramids_eo/stac/signers.py
BdcTokenSigner
#
Bases: _BaseSigner
Brazil Data Cube (BDC) OAuth-token URL signer.
Some Brazil Data Cube collections (token-gated tiers) require an
?access_token=<token> query parameter on each asset href; open
collections (the bulk of the published STAC v1 catalog) are anonymous and
do not need a token. BdcTokenSigner rewrites a clean asset href into a
token-bearing one for every read, leaving the bare-anonymous BDC reads to
the anonymous signer (the endpoint default).
BDC search itself is anonymous — sign_request is a no-op, and
sign_item does not mutate returned items. The token rides in the asset
URL's query string, not the GDAL environment, so gdal_env is empty: a
signed https://data.inpe.br/...tif?access_token=… href is read directly
through GDAL /vsicurl/ with no extra config.
The token is read from the BDC_ACCESS_TOKEN environment variable on
first use; absent it, sign_href raises AuthenticationError (from
pyramids_eo.errors) naming the env var and pointing at an open collection
so the user can switch tiers if they want. Wire it in via a
per-collection signer: bdc-token override on the token-gated rows of
catalog/bdc.yaml.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
Explicit BDC OAuth token. Defaults to |
None
|
Examples:
- A clean https href becomes a query-bearing one (passing the token explicitly so the example does not mutate the process env):
- An href that already carries a query gets
&access_token=…instead:
Source code in src/pyramids_eo/stac/signers.py
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 | |
sign_href(href)
#
Append ?access_token=<token> (or &access_token=) to the asset href.
Uses urlsplit/urlunsplit so the token lands in the URL's query
component even when the href carries a #fragment (a naive
"?" in href check would mistake a fragment for a query and append
after #, where the server never sees it).
Source code in src/pyramids_eo/stac/signers.py
available_signers()
#
Return the signer names a catalog signer: field may carry.
Lets a consumer validate a catalog value when the catalog is parsed, rather
than discovering a typo as a ValueError from :func:build_signer at the
moment a read is attempted.
Returns:
| Type | Description |
|---|---|
str
|
tuple[str, ...]: Every known signer name, in declaration order (the two |
...
|
generic signers first, then the provider signers). |
Examples:
- The generic signers lead and every name is a valid
build_signerkey: - Use it to validate a catalog value before building anything:
See Also
build_signer: Builds the signer one of these names refers to.
Source code in src/pyramids_eo/stac/signers.py
build_signer(signer_type, **creds)
#
Build the signer named by a catalog signer: field.
Dispatches through :data:_SIGNER_FACTORIES. The anonymous signer is the
pyramids-eo-local _AnonymousS3Signer and the aws-requester-pays signer
comes from pyramids.stac (imported inside its factory, so importing this
module pulls in no STAC stack); the mpc-sas / earthdata / cdse / cdse-s3 /
bdc-token provider signers are the pyramids-eo-local classes above.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signer_type
|
str
|
A name from :func: |
required |
**creds
|
Any
|
Extra credentials forwarded to the selected signer — |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
A signer satisfying the |
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
Examples:
- The MPC key maps to the native SAS signer (no SDK):
- Build the CDSE S3 signer from explicit S3 keys:
- Build the BDC token signer with an explicit token:
- An unknown signer name is rejected:
See Also
available_signers: The names this factory accepts, for validating a catalog value before building anything.
Source code in src/pyramids_eo/stac/signers.py
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 | |
CDSE S3 credentials#
pyramids_eo.stac.auth_cdse
#
CDSE S3 credential resolution for the STAC backend's cdse-s3 signer.
Copernicus Data Space (CDSE) STAC search is anonymous, but the asset bytes
live on an S3-compatible store at eodata.dataspace.copernicus.eu that needs
S3 access-key/secret credentials. Two ways to obtain them:
- (a) Dashboard keys — long-lived S3 keys generated in the CDSE dashboard
(the robust default). Supplied via the
CDSE_S3_ACCESS_KEY/CDSE_S3_SECRET_KEYenv vars or explicit kwargs. - (b) Keycloak token → temporary S3 creds — exchanged from an OAuth
password grant when only
CDSE_USERNAME/CDSE_PASSWORDare available.
s3_credentials resolves (a) first (kwarg → env). Path (b) is a planned
fallback (see planning/stac/stac-completion.md G4); until its token /
exchange endpoints are pinned, supplying only username/password raises a
clear AuthenticationError naming the dashboard URL.
s3_credentials(access_key=None, secret_key=None, **_ignored)
#
Resolve CDSE S3 (access_key, secret_key) for the cdse-s3 signer.
Resolution order: explicit kwargs, then the CDSE_S3_ACCESS_KEY /
CDSE_S3_SECRET_KEY env vars. Extra keyword arguments are ignored so the
build_signer(**creds) call site can forward a superset of kwargs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_key
|
str | None
|
CDSE S3 access key id, or |
None
|
secret_key
|
str | None
|
CDSE S3 secret key, or |
None
|
**_ignored
|
object
|
Ignored extra kwargs (forwarded by |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
The resolved |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
When neither kwargs nor env vars supply both halves of the credential pair. The message names the dashboard URL where keys are generated and the env vars to set. |
Examples:
- Explicit keys are returned as a pair (kwargs win over the env):
- Extra kwargs that
build_signerforwards are ignored: