Skip to content

docs: Correct what _validate_token claims to do - #6689

Open
larrysingleton007 wants to merge 3 commits into
feast-dev:masterfrom
larrysingleton007:docs/oidc-validate-token-honesty
Open

docs: Correct what _validate_token claims to do#6689
larrysingleton007 wants to merge 3 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

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>
@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.76%. Comparing base (a1e6fc2) to head (8d3597b).
⚠️ Report is 1 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.77%   46.76%   -0.01%     
==========================================
  Files         414      414              
  Lines       50191    50189       -2     
  Branches     7181     7181              
==========================================
- Hits        23475    23473       -2     
  Misses      25077    25077              
  Partials     1639     1639              
Flag Coverage Δ *Carryforward flag
go-feature-server 30.58% <ø> (ø)
python-unit 48.09% <100.00%> (-0.01%) ⬇️ Carriedforward from 3460f87

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...python/feast/permissions/auth/oidc_token_parser.py 73.48% <100.00%> (-0.40%) ⬇️

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 4efb86c...8d3597b. 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 ?

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>
@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.

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