Skip to content

docs: Correct what _validate_token claims to do - #6689

Merged
ntkathole merged 2 commits into
feast-dev:masterfrom
larrysingleton007:docs/oidc-validate-token-honesty
Aug 14, 2026
Merged

docs: Correct what _validate_token claims to do#6689
ntkathole merged 2 commits into
feast-dev:masterfrom
larrysingleton007:docs/oidc-validate-token-honesty

Conversation

@larrysingleton007

Copy link
Copy Markdown
Contributor

What this PR does / why we need it

OidcTokenParser._validate_token is named validate, its docstring says it validates the token against the OAuth2 server, and the caller logs "Token successfully validated" afterwards. None of that is accurate. The bearer scheme only parses an Authorization header, and the method constructs that header itself from the token it was handed, so every value passes. Verified against fastapi 0.139.2: the empty string, whitespace, and arbitrary garbage are all accepted.

The token is genuinely verified a few lines later in _decode_token, which fetches the JWKS signing key and validates the signature and claims. So authentication is sound. The problem is that anyone auditing this path reads a verification step that does not exist, and a debug log that confirms it.

This changes the docstring to describe what the call actually checks (that the discovery document exposes the OAuth2 endpoints, which is the only thing that can make it fail) and changes the log line to match.

No behavior change: docstring and one log string only. Existing tests pass unmodified.

Whether the call should exist at all is a separate question, asked in #6688, since removing it would change behavior for providers whose discovery document omits a token endpoint. This PR deliberately does not pre-empt that answer.

Which issue(s) this PR fixes

Relates to #6688

@codecov-commenter

codecov-commenter commented Jul 31, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.81%. Comparing base (01da132) to head (5a80a2b).
⚠️ Report is 5 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6689   +/-   ##
=======================================
  Coverage   46.80%   46.81%           
=======================================
  Files         415      415           
  Lines       50395    50396    +1     
  Branches     7214     7214           
=======================================
+ Hits        23587    23591    +4     
+ Misses      25155    25154    -1     
+ Partials     1653     1651    -2     
Flag Coverage Δ
go-feature-server 30.58% <ø> (ø)
python-unit 48.13% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
...python/feast/permissions/auth/oidc_token_parser.py 73.88% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fef4e78...5a80a2b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@larrysingleton007

Copy link
Copy Markdown
Contributor Author

@ntkathole @franciscojavierarceo
This has been green since Friday with no reviewer assigned. It's a small docs correction: _validate_token doesn't validate anything beyond decoding, so the docstring and the guide both overstate what it does.

Could one of you take a look, or route it to whoever owns this area? It also needs a kind/ label, which I can't add as an outside contributor.

async def _validate_token(self, access_token: str):
"""
Validate the token extracted from the header of the user request against the OAuth2 server.
"""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 ?

@larrysingleton007

Copy link
Copy Markdown
Contributor Author

@ntkathole
It was, yes. Renamed it to _check_discovery_endpoints, which is what the docstring's first line already said it does. Leaving the old name meant the docstring had to open by correcting the name, which is a smell in itself.

It's private with a single caller in the same file, so the rename is contained. I kept the access_token parameter because the bearer scheme still needs a well-formed Authorization header, and the caller has the token to hand. Happy to drop it and pass a placeholder if you'd rather make that explicit too, since the value provably can't affect the outcome.

317 permissions tests pass.

@larrysingleton007

Copy link
Copy Markdown
Contributor Author

@ntkathole @franciscojavierarceo
Still open. Your naming question was addressed on 5 August: _validate_token became _check_discovery_endpoints, which is what the docstring's first line already said it does.

The red check is worth explaining, because it isn't this PR and it looks alarming. unit-test-python (3.12, ubuntu-latest) failed on test_3rd_party_providers with:

ModuleNotFoundError: No module named 'psutil'

That's a race inside the test suite, not a missing dependency. tests/unit/infra/test_dependency_conflicts.py runs pip install kserve==0.15.2 against the live interpreter with no isolation. feast pins psutil==5.9.0 and kserve requires psutil<6.0.0,>=5.9.6, so pip cannot leave the existing version in place: it uninstalls psutil, then installs 5.9.8. I reproduced that locally and the pip log shows the window plainly.

The suite runs under xdist with 8 workers sharing one environment, so any concurrently running test that shells out to the feast CLI can land in that window and find no psutil. test_3rd_party_providers does exactly that. In this run the kserve test finished at 12:25:54 and the failure came at 12:29:15 in the same job. It's timing-dependent, which is why it's intermittent rather than reproducible on demand.

Two things worth flagging beyond this PR. Mutating the interpreter that's running the suite makes any test that shells out nondeterministic, so a re-run will probably go green without anything having changed. And separately, #6713 loosens psutil==5.9.0 to >=5.9.0 for unrelated reasons; if the lock then resolves psutil into kserve's range, pip would have nothing to uninstall and this race would close as a side effect.

Happy to open an issue for the isolation problem if that's useful. Otherwise this PR is a one-line rename plus a docstring, with no conflicts against current master.

The method is named validate, its docstring says it validates the token
against the OAuth2 server, and the caller logs 'Token successfully
validated' afterwards. None of that holds: the bearer scheme only parses
an Authorization header, and the method builds that header itself, so
every token value passes including the empty string. The token is really
verified in _decode_token.

Anyone auditing the auth path is misled into thinking a verification
step happens here. Describe what the call actually checks (that the
discovery document exposes the OAuth2 endpoints) and log that instead.

No behavior change: docstring and log message only. Whether the call
should exist at all is asked separately in feast-dev#6688.

Signed-off-by: Larry Singleton <166439969+larrysingleton007@users.noreply.github.com>
The method never verified the token it takes: it builds a bearer scheme
whose header it supplies itself, so any token value passes. What it does
check is that the discovery document exposes the OAuth2 endpoints, which
is what the docstring already said after the previous commit.

Leaving the old name meant the docstring had to spend its opening
correcting the name. Private method, single caller in the same file, so
the rename is contained.

The access_token parameter stays: the bearer scheme requires a
well-formed Authorization header, and the caller has the token to hand.

Signed-off-by: Larry Singleton <166439969+larrysingleton007@users.noreply.github.com>
@ntkathole
ntkathole force-pushed the docs/oidc-validate-token-honesty branch from 8d3597b to 5a80a2b Compare August 14, 2026 04:41
@ntkathole
ntkathole merged commit 7278dcf into feast-dev:master Aug 14, 2026
21 checks passed
@larrysingleton007
larrysingleton007 deleted the docs/oidc-validate-token-honesty branch August 14, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants