Skip to content

Commit 5f8678f

Browse files
committed
LCORE-622: ssl_mode in PostgreSQL configuration should contain just limited set of values
1 parent d2800b5 commit 5f8678f

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Constants used in business logic."""
22

3-
from typing import Final
3+
from typing import Final, Literal
44

55
# Use Final[type] as type hint for all constants to ensure that type checkers (Mypy etc.)
66
# will be able to detect assignements to such constants.
@@ -158,7 +158,7 @@
158158

159159
# PostgreSQL connection constants
160160
# See: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE
161-
POSTGRES_DEFAULT_SSL_MODE: Final[str] = "prefer"
161+
POSTGRES_DEFAULT_SSL_MODE: Final[Literal["prefer"]] = "prefer"
162162
# See: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE
163163
POSTGRES_DEFAULT_GSS_ENCMODE: Final[str] = "prefer"
164164

src/models/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ class PostgreSQLDatabaseConfiguration(ConfigurationBase):
228228
description="Database namespace",
229229
)
230230

231-
ssl_mode: str = Field(
232-
constants.POSTGRES_DEFAULT_SSL_MODE,
231+
ssl_mode: Literal[
232+
"disable", "allow", "prefer", "require", "verify-ca", "verify-full"
233+
] = Field(
234+
default=constants.POSTGRES_DEFAULT_SSL_MODE,
233235
title="SSL mode",
234236
description="SSL mode",
235237
)

0 commit comments

Comments
 (0)