-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconfig.py
More file actions
113 lines (94 loc) · 3.81 KB
/
config.py
File metadata and controls
113 lines (94 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
"""Configuration options for the Lambda backed API implementing `stac-fastapi`."""
import subprocess
from typing import Dict, Optional
from pydantic import AnyHttpUrl, Field, model_validator
from pydantic_settings import BaseSettings
class vedaSTACSettings(BaseSettings):
"""Application settings"""
env: Dict = {}
timeout: int = 30 # seconds
memory: int = 8000 # Mb
# Secret database credentials
stac_pgstac_secret_arn: Optional[str] = Field(
None,
description="Name or ARN of the AWS Secret containing database connection parameters",
)
stac_root_path: str = Field(
"",
description="Optional path prefix to add to all api endpoints",
)
raster_root_path: str = Field(
"",
description="Optional path prefix to add to all raster endpoints",
)
custom_host: Optional[str] = Field(
None,
description="Complete url of custom host including subdomain. When provided, override host in api integration",
)
project_name: Optional[str] = Field(
"VEDA (Visualization, Exploration, and Data Analysis)",
description="Name of the STAC Catalog",
)
project_description: Optional[str] = Field(
"VEDA (Visualization, Exploration, and Data Analysis) is NASA's open-source Earth Science platform in the cloud.",
description="Description of the STAC Catalog",
)
keycloak_stac_api_client_id: Optional[str] = Field(
None, description="Auth client ID"
)
openid_configuration_url: Optional[AnyHttpUrl] = Field(
None, description="OpenID config url"
)
stac_enable_transactions: bool = Field(
False, description="Whether to enable transactions endpoints"
)
disable_default_apigw_endpoint: Optional[bool] = Field(
False,
description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false.",
)
pystac_stac_version_override: Optional[str] = Field(
"1.0.0",
description="Stac version override for Pystac validations https://pystac.readthedocs.io/en/stable/api/version.html",
)
git_sha: Optional[str] = Field(
subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode("utf-8"),
description="Git SHA of the current commit, used to track deployment version",
)
enable_stac_auth_proxy: bool = Field(
False,
description="Whether to enable STAC Auth Proxy. If enable_transactions is True, this must also be True.",
)
keycloak_uma_resource_server_client_secret_name: Optional[str] = Field(
None,
description="Name of AWS Secrets Manager secret containing Keycloak UMA resource server client_id and client_secret",
)
keycloak_secret_kms_key_arn: Optional[str] = Field(
None,
description="ARN of KMS key used to encrypt the Keycloak secret",
)
@model_validator(mode="before")
def check_transaction_fields(cls, values):
"""
Validates the existence of auth env vars in case stac_enable_transactions is True
"""
if values.get("stac_enable_transactions") == "True":
missing_fields = [
field
for field in [
"keycloak_stac_api_client_id",
"openid_configuration_url",
"enable_stac_auth_proxy",
]
if not values.get(field)
]
if missing_fields:
raise ValueError(
f"When 'stac_enable_transactions' is True, the following fields must be provided: {', '.join(missing_fields)}"
)
return values
class Config:
"""model config"""
env_file = ".env"
env_prefix = "VEDA_"
extra = "ignore"
veda_stac_settings = vedaSTACSettings()