From fb2d492fbe008b29973a0eae1ef85779d46d0e8b Mon Sep 17 00:00:00 2001 From: Sean <63349506+SerRichard@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:17:24 +0200 Subject: [PATCH] update the settings (#60) * update the settings to handle situations where the variable has not been cleaned * fix version typo --- openeo_fastapi/client/settings.py | 11 +++++++---- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/openeo_fastapi/client/settings.py b/openeo_fastapi/client/settings.py index 77f91dd..1327f6c 100644 --- a/openeo_fastapi/client/settings.py +++ b/openeo_fastapi/client/settings.py @@ -58,9 +58,14 @@ def ensure_endswith_slash(cls, v: str) -> str: return v.__add__("/") @validator("OIDC_POLICIES", pre=True) - def split_oidc_policies_str_to_list(cls, v: str) -> str: + def split_oidc_policies_str_to_list(cls, v: list) -> str: """Ensure the OIDC_POLICIES are split and formatted correctly.""" + if isinstance(v, str): + # We shouldn't have a string here. But in some cases where the settings where taken from code and not an env variable + # the config function parse_env_var will not execute. Reclean the value here if that is the case. + v = [str(x) for x in v.split("&&") if x != ""] + if not v: return v @@ -86,8 +91,6 @@ def parse_env_var(cls, field_name: str, raw_val: str) -> Any: """Parse any variables and handle and csv lists into python list type.""" if field_name == "STAC_COLLECTIONS_WHITELIST": return [str(x) for x in raw_val.split(",")] - elif field_name == "OIDC_ROLES": - return [str(x) for x in raw_val.split(",")] elif field_name == "OIDC_POLICIES": - return [str(x) for x in raw_val.split("&&")] + return [str(x) for x in raw_val.split("&&") if x != ""] return cls.json_loads(raw_val) diff --git a/pyproject.toml b/pyproject.toml index aeb5520..52c9f59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "openeo-fastapi" -version = "2024.9.2" +version = "2024.10.1" description = "FastApi implementation conforming to the OpenEO Api specification." authors = ["Sean Hoyal "] readme = "README.md"