-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update bento_lib + use new lib utils + update base imgs
- Loading branch information
1 parent
1976487
commit 2b54658
Showing
8 changed files
with
689 additions
and
762 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
import json | ||
|
||
from bento_lib.config.pydantic import BentoBaseConfig | ||
from fastapi import Depends | ||
from functools import lru_cache | ||
from pydantic.fields import FieldInfo | ||
from pydantic_settings import BaseSettings, EnvSettingsSource, PydanticBaseSettingsSource, SettingsConfigDict | ||
from typing import Annotated, Any, Literal | ||
from typing import Annotated | ||
|
||
from .constants import SERVICE_GROUP, SERVICE_ARTIFACT | ||
|
||
|
@@ -15,23 +12,15 @@ | |
] | ||
|
||
|
||
class CorsOriginsParsingSource(EnvSettingsSource): | ||
def prepare_field_value(self, field_name: str, field: FieldInfo, value: Any, value_is_complex: bool) -> Any: | ||
if field_name == "cors_origins": | ||
return tuple(x.strip() for x in value.split(";")) if value is not None else () | ||
return json.loads(value) if value_is_complex else value | ||
|
||
|
||
class Config(BaseSettings): | ||
bento_debug: bool = False | ||
class Config(BentoBaseConfig): | ||
# the superclass has this as a required field - we ignore it since this IS the authz service | ||
# TODO: should this maybe be a [str | None] in bento_lib? | ||
bento_authz_service_url: str = "" | ||
|
||
service_id: str = f"{SERVICE_GROUP}:{SERVICE_ARTIFACT}" | ||
service_name: str = "Bento Authorization Service" | ||
service_url_base_path: str = "http://127.0.0.1:5000" # Base path to construct URIs from | ||
|
||
# /service-info customization | ||
service_contact_url: str = "mailto:[email protected]" | ||
|
||
database_uri: str = "postgres://localhost:5432" | ||
|
||
# OpenID well-known URL of the instance Identity Provider to extract endpoints from | ||
|
@@ -44,24 +33,6 @@ class Config(BaseSettings): | |
# - Default set of disabled 'insecure' algorithms (in this case symmetric key algorithms) | ||
disabled_token_signing_algorithms: frozenset = frozenset(["HS256", "HS384", "HS512"]) | ||
|
||
cors_origins: tuple[str, ...] | ||
|
||
log_level: Literal["debug", "info", "warning", "error"] = "debug" | ||
|
||
# Make Config instances hashable + immutable | ||
model_config = SettingsConfigDict(frozen=True) | ||
|
||
@classmethod | ||
def settings_customise_sources( | ||
cls, | ||
settings_cls: type[BaseSettings], | ||
init_settings: PydanticBaseSettingsSource, | ||
env_settings: PydanticBaseSettingsSource, | ||
dotenv_settings: PydanticBaseSettingsSource, | ||
file_secret_settings: PydanticBaseSettingsSource, | ||
) -> tuple[PydanticBaseSettingsSource, ...]: | ||
return (CorsOriginsParsingSource(settings_cls),) | ||
|
||
|
||
@lru_cache() | ||
def get_config() -> Config: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.