forked from mtusi2026/mtusi2026lab7
feat: require TLS to PostgreSQL, Valkey and S3
Storage servers accept only TLS 1.3 (pg_hba hostssl / hostnossl reject, Valkey port 0, S3 gateway HTTPS only) with stand identities postgres, valkey and s3. Clients trust only the stand CA from [client_tls] ca_file and check the host name; no switch to disable verification. Processes exit with code 2 without a CA or with an IP storage address. Temporary stands, CI and bench/ run on TLS storages; make storage_tls_check adds negative checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+20
-2
@@ -263,8 +263,10 @@ class S3(BaseModel):
|
||||
|
||||
@property
|
||||
def endpoint_url(self) -> str:
|
||||
"""Адрес API S3; клиент сам URL не собирает."""
|
||||
return f"http://{self.host}:{self.port}"
|
||||
"""Адрес API S3; клиент сам URL не собирает. С change `storage-tls`
|
||||
— только HTTPS: шлюз HTTP не принимает, проверку сертификата по
|
||||
`[client_tls] ca_file` и имени `host` делает клиент."""
|
||||
return f"https://{self.host}:{self.port}"
|
||||
|
||||
|
||||
class Idempotency(BaseModel):
|
||||
@@ -613,6 +615,21 @@ class ApiTls(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class ClientTls(BaseModel):
|
||||
"""Доверие клиентов процесса к серверам зависимостей (change
|
||||
`storage-tls`, design, решение 5): PostgreSQL, Valkey и S3 проверяются
|
||||
по этому CA и имени хоста, системное хранилище CA не используется.
|
||||
|
||||
Путь задают compose (`CLIENT_TLS__CA_FILE: /run/secrets/ca.crt`) и цели
|
||||
make консоли (`$(PKI_STAND_DIR)/ca.crt`), в `config.toml` поля нет.
|
||||
Проверяют точки входа при старте (`client_tls_problems`), а не валидатор
|
||||
модели: `Settings` загружается и без файлов.
|
||||
"""
|
||||
|
||||
# путь к PEM сертификата CA стенда
|
||||
ca_file: str = ""
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(
|
||||
extra="ignore",
|
||||
@@ -636,6 +653,7 @@ class Settings(BaseSettings):
|
||||
relay: Relay = Relay()
|
||||
telemetry: Telemetry = Telemetry()
|
||||
api_tls: ApiTls = ApiTls()
|
||||
client_tls: ClientTls = ClientTls()
|
||||
|
||||
@field_validator("auth")
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user