http/auth: close intermediate peer ID auth handshake responses#3510
Open
Sahil-4555 wants to merge 6 commits into
Open
http/auth: close intermediate peer ID auth handshake responses#3510Sahil-4555 wants to merge 6 commits into
Sahil-4555 wants to merge 6 commits into
Conversation
Contributor
Author
|
@sukunrt if you got chance can you please review this PR? and can provide feedback |
Collaborator
|
I've made changes to this PR. I'll push them soon. |
Collaborator
Please do not ping maintainers. We can see this in our backlog, and will prioritize it appropriately. |
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.
This fixes a resource leak in the HTTP peer ID auth client. During a multi-step authentication flow, the client sends intermediate requests before returning the final authenticated response to the caller. Those intermediate responses are only used for their auth headers, so the library owns their bodies and must close them.
Before this change, those handshake-only response bodies were left open. A server that forces first-time authentication or repeatedly rejects cached bearer tokens could make a long-running client retain HTTP transport resources across repeated handshakes.
The fix closes every non-final response body inside the handshake loop while preserving the existing API contract: the final authenticated response is still returned open and remains the caller’s responsibility.
The tests cover both normal first-contact authentication and the cached-token rejection path that triggers reauthentication.