Skip to content

Commit e6921d4

Browse files
committed
Simplify configuration, keep detailed config on handler class
1 parent 3e301bc commit e6921d4

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,10 @@ The application is configurable via environment variables.
145145
- **Type:** JSON object
146146
- **Required:** No, defaults to `null` (disabled)
147147
- **Example:** `{"type": "http", "scheme": "bearer", "bearerFormat": "JWT", "description": "Paste your raw JWT here. This API uses Bearer token authorization.\n"}`
148-
- **`SWAGGER_UI_URL`**, path of Swagger UI, used for augmenting spec response with auth configuration
148+
- **`SWAGGER_UI_ENDPOINT`**, path of Swagger UI, used for augmenting spec response with auth configuration
149149
- **Type:** string or null
150150
- **Required:** No, defaults to `/api.html`
151151
- **Example:** `/api`
152-
- **`SWAGGER_UI_TITLE`**, title of the Swagger UI
153-
- **Type:** string
154-
- **Required:** No, defaults to `STAC API`
155-
- **Example:** `Foo API`
156152
- **`SWAGGER_UI_INIT_OAUTH`**, initialization options for the [Swagger UI OAuth2 configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/)
157153
- **Type:** JSON object
158154
- **Required:** No, defaults to `null` (disabled)

src/stac_auth_proxy/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ async def lifespan(app: FastAPI):
7878
# Handlers (place catch-all proxy handler last)
7979
#
8080

81-
if settings.swagger_ui_url:
81+
if settings.swagger_ui_endpoint:
8282
assert (
8383
settings.openapi_spec_endpoint
8484
), "openapi_spec_endpoint must be set when using swagger_ui_url"
8585
app.add_route(
86-
settings.swagger_ui_url,
86+
settings.swagger_ui_endpoint,
8787
SwaggerUI(
8888
openapi_url=settings.openapi_spec_endpoint,
8989
title=settings.swagger_ui_title,

src/stac_auth_proxy/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ class Settings(BaseSettings):
5151
)
5252
openapi_auth_scheme_name: str = "oidcAuth"
5353
openapi_auth_scheme_override: Optional[dict] = None
54-
swagger_ui_url: Optional[str] = "/api.html"
55-
swagger_ui_title: Optional[str] = "STAC API"
54+
swagger_ui_endpoint: Optional[str] = "/api.html"
5655
swagger_ui_init_oauth: dict = Field(default_factory=dict)
5756

5857
# Auth

src/stac_auth_proxy/handlers/swagger_ui.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class SwaggerUI:
2222
openapi_url: str
2323
title: Optional[str] = "STAC API"
2424
init_oauth: dict = field(default_factory=dict)
25+
parameters: dict = field(default_factory=dict)
2526
oauth2_redirect_url: str = "/docs/oauth2-redirect"
2627

2728
async def route(self, req: Request) -> HTMLResponse:
@@ -36,5 +37,5 @@ async def route(self, req: Request) -> HTMLResponse:
3637
title=f"{self.title} - Swagger UI",
3738
oauth2_redirect_url=oauth2_redirect_url,
3839
init_oauth=self.init_oauth,
39-
swagger_ui_parameters=None,
40+
swagger_ui_parameters=self.parameters,
4041
)

0 commit comments

Comments
 (0)