Repository navigation
Conversation
- Scopes are compared exactly. Before, a substring check of the `scope` claim meant a token with scope "ab" passed a required "a". - A token without a `scope` claim on a scoped route gets 401 instead of an internal error. - Reject an empty bearer token. - Never log the Authorization header or the token; log only the exception class. - Require the `exp` and `iss` claims by default and check `iss` against the issuer from the discovery document. Both can be set with the new `issuer` and `required_claims` options (also in OpenIdConnectSettings). - `create_auth_token_dependency` accepts `issuer`/`required_claims` as keyword-only arguments and keeps its old behaviour by default. BREAKING CHANGE: tokens without `exp` or `iss`, or whose `iss` differs from the discovery document's `issuer`, are rejected. Set `required_claims=()` to restore the previous behaviour, or `issuer` when the service fetches discovery from an internal URL with another issuer.
- Discovery requests get a timeout (`discovery_timeout`, default 10s); before, an unresponsive IdP could block startup indefinitely. - Any failure (HTTP error, unreachable host, timeout, invalid JSON, no `jwks_uri`) raises OidcFetchError. The previous non-200 branch was unreachable (urlopen raises HTTPError) and would have failed on the nonexistent `response.text`. - Keep the discovery document as `openid_configuration` (e.g. for `token_endpoint`), expose `discovered`, and add a thread-safe, idempotent `discover()`.
|
Claude finished @pantierra's task in 17s —— View job ✅ No blocking issues — safe to merge. I read the diff for
Simplify (ponytail) — advisory only
💰 Estimated review cost: $0.11 · 0m16s · 5 turns |
- Pass the validate function to _validate_header directly. - Fetch the discovery document in __post_init__; drop discover(), the lock and `discovered`, which nothing in this PR needs. - Check `iss` only when it is required, so `required_claims=()` keeps the old behaviour without a manual issuer comparison. - Catch all discovery errors with one `except`; urlopen already raises for non-2xx responses.
- Fold _decode into _validate_header and drop the validate callable. - Drop the None return for a missing header; Security(auth_scheme) already rejects it, and an empty header fails the bearer check. - create_auth_token_dependency requires `issuer` and `required_claims` so a direct caller can't turn the checks off by accident.
- _unauthorized takes the WWW-Authenticate challenge, so the missing scope error reuses it; drop BEARER_CHALLENGE. - create_auth_token_dependency binds its arguments with functools.partial.
An unreachable JWKS still gives 401, but is now logged at warning so operators see a provider outage. The README notes that only the space-separated `scope` claim is read.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stricter login token checks, and safer loading of the login server's settings.
Token checks
abwas accepted where scopeawas required.401. Before, the server crashed with an error.exp) and an issuer (iss), and the issuer must be our login server.Loading the login server's settings
discovery_timeout). Before, the app could hang at startup forever.OidcFetchError.Breaking change
Tokens without
exporiss, or with a different issuer, are rejected now.required_claims=().issuerto the public one.