11"""Configuration for the STAC Auth Proxy."""
22
33import importlib
4- from typing import Optional , Sequence , TypeAlias
4+ from typing import Literal , Optional , Sequence , TypeAlias
55
66from pydantic import BaseModel , Field
77from pydantic .networks import HttpUrl
88from pydantic_settings import BaseSettings , SettingsConfigDict
99
10- EndpointMethods : TypeAlias = dict [str , list [str ]]
10+ EndpointMethods : TypeAlias = dict [
11+ str , list [Literal ["GET" , "POST" , "PUT" , "DELETE" , "PATCH" ]]
12+ ]
1113_PREFIX_PATTERN = r"^/.*$"
1214
1315
@@ -29,12 +31,21 @@ def __call__(self):
2931class Settings (BaseSettings ):
3032 """Configuration settings for the STAC Auth Proxy."""
3133
32- upstream_url : HttpUrl = HttpUrl (url = "https://earth-search.aws.element84.com/v1" )
34+ # External URLs
35+ upstream_url : HttpUrl
3336 oidc_discovery_url : HttpUrl
3437
3538 # Endpoints
3639 healthz_prefix : str = Field (pattern = _PREFIX_PATTERN , default = "/healthz" )
40+ openapi_spec_endpoint : Optional [str ] = Field (pattern = _PREFIX_PATTERN , default = None )
41+
42+ # Auth
3743 default_public : bool = False
44+ public_endpoints : EndpointMethods = {
45+ r"^/api.html$" : ["GET" ],
46+ r"^/api$" : ["GET" ],
47+ r"^/healthz" : ["GET" ],
48+ }
3849 private_endpoints : EndpointMethods = {
3950 # https://github.com/stac-api-extensions/collection-transaction/blob/v1.0.0-beta.1/README.md#methods
4051 r"^/collections$" : ["POST" ],
@@ -45,18 +56,12 @@ class Settings(BaseSettings):
4556 # https://stac-utils.github.io/stac-fastapi/api/stac_fastapi/extensions/third_party/bulk_transactions/#bulktransactionextension
4657 r"^/collections/([^/]+)/bulk_items$" : ["POST" ],
4758 }
48- public_endpoints : EndpointMethods = {r"^/api.html$" : ["GET" ], r"^/api$" : ["GET" ]}
49- openapi_spec_endpoint : Optional [str ] = None
50-
51- # collections_filter: Optional[ClassInput] = None
52- # collections_filter_endpoints: Optional[EndpointMethods] = {
53- # r"^/collections$": ["GET"],
54- # r"^/collections$/([^/]+)": ["GET"],
55- # }
59+
60+ # Filters
5661 items_filter : Optional [ClassInput ] = None
5762 items_filter_endpoints : Optional [EndpointMethods ] = {
5863 r"^/search$" : ["POST" ],
5964 r"^/collections/([^/]+)/items$" : ["GET" , "POST" ],
6065 }
6166
62- model_config = SettingsConfigDict (env_prefix = "STAC_AUTH_PROXY_" )
67+ model_config = SettingsConfigDict ()
0 commit comments