Skip to content

Commit 6a13f22

Browse files
committed
Cleanup
1 parent a213937 commit 6a13f22

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/stac_auth_proxy/middleware/EnforceAuthMiddleware.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import urllib.request
66

77
from fastapi import HTTPException, Security, security, status, Request
8-
from fastapi.security.base import SecurityBase
98
from pydantic import HttpUrl
109
from starlette.middleware.base import ASGIApp
1110
from starlette.responses import JSONResponse
12-
from starlette.types import ASGIApp, Message, Receive, Scope, Send
11+
from starlette.types import ASGIApp, Receive, Scope, Send
1312
import jwt
1413

1514
from ..config import EndpointMethods
@@ -32,7 +31,6 @@ class EnforceAuthMiddleware:
3231
allowed_jwt_audiences: Optional[Sequence[str]] = None
3332

3433
# Generated attributes
35-
# auth_scheme: SecurityBase = field(init=False)
3634
jwks_client: jwt.PyJWKClient = field(init=False)
3735

3836
def __post_init__(self):
@@ -51,11 +49,6 @@ def __post_init__(self):
5149
oidc_config = json.load(response)
5250
self.jwks_client = jwt.PyJWKClient(oidc_config["jwks_uri"])
5351

54-
# self.auth_scheme = security.OpenIdConnect(
55-
# openIdConnectUrl=str(self.oidc_config_url),
56-
# auto_error=False,
57-
# )
58-
5952
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
6053
"""Enforce authentication."""
6154
if scope["type"] != "http":
@@ -65,7 +58,6 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
6558
try:
6659
scope["state"]["user"] = self.validated_user(
6760
request.headers.get("Authorization"),
68-
security.SecurityScopes(scopes=["read"]),
6961
auto_error=self.should_enforce_auth(request),
7062
)
7163
except HTTPException as e:
@@ -84,7 +76,6 @@ def should_enforce_auth(self, request: Request) -> bool:
8476
def validated_user(
8577
self,
8678
auth_header: Annotated[str, Security(...)],
87-
required_scopes: security.SecurityScopes,
8879
auto_error: bool = True,
8980
):
9081
"""Dependency to validate an OIDC token."""

0 commit comments

Comments
 (0)