Repository navigation
Decouple transports from token lifecycle #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3a3ffd7
Support direct HTTPX adapters without token providers
kdubb 6e33f4c
Remove token coupling from HTTPX transport and SSE
kdubb c22b558
Make authentication stop policy explicit through adapters
kdubb 4a8e903
Type regression tests under full CI checks
kdubb a776db1
Compose standard authentication explicitly for generated clients
kdubb f02275f
Preserve explicit rejection policy and private adapter state
kdubb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| """Redact operation-designated credential locations without acquiring or interpreting tokens.""" | ||
|
|
||
| import httpx | ||
|
|
||
| from ..request_cancellation_error import RequestCancellationError | ||
| from ._request_context import clear_request_context | ||
| from ._requests import copy_request | ||
| from .request_security_bindings import request_security_bindings | ||
|
|
||
|
|
||
| def diagnostic_request(request: httpx.Request) -> httpx.Request: | ||
| """Remove sensitive values from native response and failure diagnostics.""" | ||
| bindings = request_security_bindings(request) | ||
| url, headers = request.url, httpx.Headers(request.headers) | ||
| for binding in bindings: | ||
| transport = binding.transport | ||
| if transport.location == "query": | ||
| url = url.copy_set_param(transport.name, "[redacted]") | ||
| elif transport.location == "header": | ||
| headers[transport.name] = "[redacted]" | ||
| else: | ||
| headers["cookie"] = "[redacted]" | ||
| return clear_request_context(copy_request(request, url=url, headers=headers)) | ||
|
|
||
|
|
||
| def diagnostic_error(error: BaseException, request: httpx.Request) -> BaseException: | ||
| """Preserve cancellation while removing sensitive request data from HTTPX failures.""" | ||
| if not request_security_bindings(request) or isinstance(error, RequestCancellationError): | ||
| return error | ||
| diagnostic = diagnostic_request(request) | ||
| if isinstance(error, httpx.HTTPStatusError): | ||
| error.response.request = diagnostic | ||
| return type(error)("HTTP request failed", request=diagnostic, response=error.response) | ||
| if isinstance(error, httpx.RequestError): | ||
| return type(error)("HTTP request failed", request=diagnostic) | ||
| return error |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| """Private adapter state retained only during a managed exchange.""" | ||
|
|
||
| from typing import cast | ||
|
|
||
| import httpx | ||
|
|
||
| _KEY = "sunday.request_context" | ||
|
|
||
|
|
||
| def request_context(request: httpx.Request) -> dict[object, object]: | ||
| """Share adapter receipts through native request copies within an exchange.""" | ||
| return cast(dict[object, object], request.extensions.setdefault(_KEY, {})) | ||
|
|
||
|
|
||
| def clear_request_context(request: httpx.Request) -> httpx.Request: | ||
| """Detach private adapter state without altering native extensions or shared copies.""" | ||
| request.extensions.pop(_KEY, None) | ||
| return request |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.