From d9d0ca122034de52dff94cc299a6de3afb792346 Mon Sep 17 00:00:00 2001 From: Anthony Lukach Date: Thu, 4 Sep 2025 08:47:05 -0700 Subject: [PATCH 1/2] refactor(config): restructure settings classes for STAC Auth Proxy - Renamed `Settings` class to `CoreSettings` and created a new `ProxySettings` class that inherits from it. - Updated imports in `__init__.py` to include `CoreSettings` and `ProxySettings`. - Adjusted configuration structure to better organize settings related to proxy functionality. --- src/stac_auth_proxy/__init__.py | 4 +++- src/stac_auth_proxy/config.py | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/stac_auth_proxy/__init__.py b/src/stac_auth_proxy/__init__.py index 4fdde39e..ef002f39 100644 --- a/src/stac_auth_proxy/__init__.py +++ b/src/stac_auth_proxy/__init__.py @@ -7,7 +7,7 @@ """ from .app import configure_app, create_app -from .config import Settings +from .config import CoreSettings, ProxySettings, Settings from .lifespan import build_lifespan __all__ = [ @@ -15,4 +15,6 @@ "create_app", "configure_app", "Settings", + "ProxySettings", + "CoreSettings", ] diff --git a/src/stac_auth_proxy/config.py b/src/stac_auth_proxy/config.py index d610420c..a43929de 100644 --- a/src/stac_auth_proxy/config.py +++ b/src/stac_auth_proxy/config.py @@ -40,17 +40,14 @@ def __call__(self): return cls(*self.args, **self.kwargs) -class Settings(BaseSettings): +class CoreSettings(BaseSettings): """Configuration settings for the STAC Auth Proxy.""" # External URLs - upstream_url: HttpUrl oidc_discovery_url: HttpUrl oidc_discovery_internal_url: HttpUrl allowed_jwt_audiences: Optional[Sequence[str]] = None - root_path: str = "" - override_host: bool = True healthz_prefix: str = Field(pattern=_PREFIX_PATTERN, default="/healthz") wait_for_upstream: bool = True check_conformance: bool = True @@ -112,3 +109,15 @@ def _default_oidc_discovery_internal_url(cls, data: Any) -> Any: def parse_audience(cls, v) -> Optional[Sequence[str]]: """Parse a comma separated string list of audiences into a list.""" return str2list(v) + + +class ProxySettings(CoreSettings): + """Configuration settings for the STAC Auth Proxy.""" + + # Proxy Configuration + upstream_url: HttpUrl + root_path: str = "" + override_host: bool = True + + +Settings = ProxySettings From ef9000b64b26efe66cb0d636df161bbfb15a05a5 Mon Sep 17 00:00:00 2001 From: Anthony Lukach Date: Thu, 4 Sep 2025 09:27:50 -0700 Subject: [PATCH 2/2] Use core settings for middleware helper --- src/stac_auth_proxy/app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stac_auth_proxy/app.py b/src/stac_auth_proxy/app.py index b1b1a6ea..1bc353b1 100644 --- a/src/stac_auth_proxy/app.py +++ b/src/stac_auth_proxy/app.py @@ -11,7 +11,7 @@ from fastapi import FastAPI from starlette_cramjam.middleware import CompressionMiddleware -from .config import Settings +from .config import CoreSettings, Settings from .handlers import HealthzHandler, ReverseProxyHandler, SwaggerUI from .lifespan import build_lifespan from .middleware import ( @@ -33,7 +33,7 @@ def configure_app( app: FastAPI, - settings: Optional[Settings] = None, + settings: Optional[CoreSettings] = None, **settings_kwargs: Any, ) -> FastAPI: """ @@ -51,7 +51,7 @@ def configure_app( ``settings`` is not provided. """ - settings = settings or Settings(**settings_kwargs) + settings = settings or CoreSettings(**settings_kwargs) # # Route Handlers