docs: Correct what _validate_token claims to do - #6689
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
@ntkathole @franciscojavierarceo Could one of you take a look, or route it to whoever owns this area? It also needs a |
| 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. |
There was a problem hiding this comment.
isn't the function name misleading then ?
|
@ntkathole It's private with a single caller in the same file, so the rename is contained. I kept the 317 permissions tests pass. |
|
@ntkathole @franciscojavierarceo The red check is worth explaining, because it isn't this PR and it looks alarming. That's a race inside the test suite, not a missing dependency. 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. 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 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>
8d3597b to
5a80a2b
Compare
What this PR does / why we need it
OidcTokenParser._validate_tokenis 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 anAuthorizationheader, 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