Skip to content

Commit 37f41de

Browse files
committed
bugfix: place auth middleware after cql2 middleware to ensure correct order
1 parent 0780294 commit 37f41de

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/stac_auth_proxy/app.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ def create_app(settings: Optional[Settings] = None) -> FastAPI:
3333
)
3434

3535
app.add_middleware(AddProcessTimeHeaderMiddleware)
36-
app.add_middleware(
37-
EnforceAuthMiddleware,
38-
public_endpoints=settings.public_endpoints,
39-
private_endpoints=settings.private_endpoints,
40-
default_public=settings.default_public,
41-
oidc_config_url=settings.oidc_discovery_url,
42-
)
4336

4437
if settings.openapi_spec_endpoint:
4538
app.add_middleware(
@@ -58,14 +51,22 @@ def create_app(settings: Optional[Settings] = None) -> FastAPI:
5851
items_filter=settings.items_filter(),
5952
)
6053

54+
app.add_middleware(
55+
EnforceAuthMiddleware,
56+
public_endpoints=settings.public_endpoints,
57+
private_endpoints=settings.private_endpoints,
58+
default_public=settings.default_public,
59+
oidc_config_url=settings.oidc_discovery_url,
60+
)
61+
6162
if settings.debug:
6263
app.add_api_route(
6364
"/_debug",
6465
lambda: {"settings": settings},
6566
methods=["GET"],
6667
)
6768

68-
# Catchall for remainder of the endpoints
69+
# Catchall for any endpoint
6970
proxy_handler = ReverseProxyHandler(upstream=str(settings.upstream_url))
7071
app.add_api_route(
7172
"/{path:path}",

0 commit comments

Comments
 (0)