Skip to content

Commit 046c731

Browse files
committed
feat: tooling to disable auth extension & compression
1 parent 0d58b35 commit 046c731

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ The application is configurable via environment variables.
7777
- **Type:** boolean
7878
- **Required:** No, defaults to `true`
7979
- **Example:** `false`, `1`, `True`
80+
- **`ENABLE_COMPRESSION`**, enable response compression
81+
- **Type:** boolean
82+
- **Required:** No, defaults to `true`
83+
- **Example:** `false`, `1`, `True`
8084
- **`HEALTHZ_PREFIX`**, path prefix for health check endpoints
8185
- **Type:** string
8286
- **Required:** No, defaults to `/healthz`
@@ -117,6 +121,10 @@ The application is configurable via environment variables.
117121
"^/healthz": ["GET"]
118122
}
119123
```
124+
- **`ENABLE_AUTHENTICATION_EXTENSION`**, enable authentication extension in STAC API responses
125+
- **Type:** boolean
126+
- **Required:** No, defaults to `true`
127+
- **Example:** `false`, `1`, `True`
120128
- **`OPENAPI_SPEC_ENDPOINT`**, path of OpenAPI specification, used for augmenting spec response with auth configuration
121129
- **Type:** string or null
122130
- **Required:** No, defaults to `null` (disabled)

src/stac_auth_proxy/app.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ async def lifespan(app: FastAPI):
8787
#
8888
# Middleware (order is important, last added = first to run)
8989
#
90-
app.add_middleware(
91-
AuthenticationExtensionMiddleware,
92-
default_public=settings.default_public,
93-
public_endpoints=settings.public_endpoints,
94-
private_endpoints=settings.private_endpoints,
95-
)
90+
if settings.enable_authentication_extension:
91+
app.add_middleware(
92+
AuthenticationExtensionMiddleware,
93+
default_public=settings.default_public,
94+
public_endpoints=settings.public_endpoints,
95+
private_endpoints=settings.private_endpoints,
96+
)
9697

9798
if settings.openapi_spec_endpoint:
9899
app.add_middleware(
@@ -113,9 +114,10 @@ async def lifespan(app: FastAPI):
113114
items_filter=settings.items_filter(),
114115
)
115116

116-
app.add_middleware(
117-
CompressionMiddleware,
118-
)
117+
if settings.enable_compression:
118+
app.add_middleware(
119+
CompressionMiddleware,
120+
)
119121

120122
app.add_middleware(
121123
AddProcessTimeHeaderMiddleware,

src/stac_auth_proxy/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class Settings(BaseSettings):
4040

4141
wait_for_upstream: bool = True
4242
check_conformance: bool = True
43-
44-
# Endpoints
43+
enable_compression: bool = True
44+
enable_authentication_extension: bool = True
4545
healthz_prefix: str = Field(pattern=_PREFIX_PATTERN, default="/healthz")
4646
openapi_spec_endpoint: Optional[str] = Field(pattern=_PREFIX_PATTERN, default=None)
4747

0 commit comments

Comments
 (0)