Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions sdk/python/feast/permissions/auth/oidc_token_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,18 @@ def _get_jwks_client(self) -> PyJWKClient:
)
return self._jwks_client

async def _validate_token(self, access_token: str):
"""
Validate the token extracted from the header of the user request against the OAuth2 server.
async def _check_discovery_endpoints(self, access_token: str):
"""Check that the provider's discovery document exposes the OAuth2 endpoints.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the function name misleading then ?


This does **not** verify *access_token*, despite taking it: the bearer
scheme below only parses an ``Authorization`` header, and this method
supplies that header itself, so any token value passes. The token is
genuinely verified in ``_decode_token``, which checks the signature
against the provider's JWKS and validates the claims.

What can fail here is constructing the scheme, which reads the token
and authorization endpoints from the discovery document. A document
missing either one raises before any token is inspected.
"""
# FastAPI's OAuth2AuthorizationCodeBearer requires a Request type but actually uses only the headers field
# https://github.com/tiangolo/fastapi/blob/eca465f4c96acc5f6a22e92fd2211675ca8a20c8/fastapi/security/oauth2.py#L380
Expand Down Expand Up @@ -218,8 +227,8 @@ async def user_details_from_access_token(self, access_token: str) -> User:

# Standard OIDC / Keycloak flow
try:
await self._validate_token(access_token)
logger.debug("Token successfully validated.")
await self._check_discovery_endpoints(access_token)
logger.debug("OIDC discovery document exposes the expected endpoints.")
except Exception as e:
if self._is_ssl_error(e):
logger.error(
Expand Down
Loading