feat: add token_endpoint_verify for custom CA on token requests#896
Open
liudonggalaxy wants to merge 1 commit into
Open
feat: add token_endpoint_verify for custom CA on token requests#896liudonggalaxy wants to merge 1 commit into
liudonggalaxy wants to merge 1 commit into
Conversation
692c4c7 to
dad99c5
Compare
1a775e8 to
76410d0
Compare
…quests Allow configuring a separate TLS verify value specifically for token endpoint requests (fetch_token, refresh_token). This enables using a custom CA certificate for the token endpoint while keeping the default verification for resource requests. Both OAuth2Session (OAuth2Client) and AssertionSession (AssertionClient) support the new token_endpoint_verify parameter.
76410d0 to
cc0d926
Compare
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.
What kind of change does this PR introduce?
Feature implementation.
What is the current behavior?
When fetching or refreshing an OAuth2 access token, the TLS
verifysetting uses the same value as regular resource requests (session-levelverify). There is no way to specify a different CA certificate bundle specifically for the token endpoint.This is problematic when the token endpoint uses a different certificate chain (e.g., an internal CA) than the resource endpoints.
What is the new behavior?
A new
token_endpoint_verifyparameter is available on bothOAuth2Session(viaOAuth2Client) andAssertionSession(viaAssertionClient). When set, it is used as theverifyvalue for token endpoint requests (fetch_tokenandrefresh_token), while regular resource requests remain unaffected.Before
After
The same works for
AssertionSession:If an explicit
verifykwarg is passed tofetch_token(), it takes precedence overtoken_endpoint_verify.Notes
requestsintegration whereverifyis a per-request parameter.httpxintegration,verifyis a client-level setting (not per-request), sotoken_endpoint_verifyis accepted but has no effect for httpx clients. A future enhancement could address this with a custom transport.Checklist
prek.pragma: no cover