Skip to content
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

proposal: net/http: add support for proxy basic authentication #55290

Closed
shalev67 opened this issue Sep 20, 2022 · 7 comments
Closed

proposal: net/http: add support for proxy basic authentication #55290

shalev67 opened this issue Sep 20, 2022 · 7 comments

Comments

@shalev67
Copy link

The current implementation of the http.Reuest allows parsing and setting the basic authentication username and password using the BasicAuth and SetBasicAuth methods. When authenticating to a http proxy server the http client and server are using a different header for the basic authentication - "Proxy-Authorization" described in RFC 2068, Section 14. Supporting parsing and setting proxy basic authentication is currently not covered in the net/http package and would be very helpful when programming http proxy client/server.

To help tackle this, I propose the following API:

// ProxyBasicAuth returns the username and password provided in the request's
// Proxy-Authorization header, if the request uses HTTP Basic Authentication.
// See RFC 2068, Section 14.
(r *Request) ProxyBasicAuth() (username, password string, ok bool)

// SetProxyBasicAuth sets the request's Proxy-Authorization header to use HTTP
// Basic Authentication with the provided username and password.
(r *Request) SetProxyBasicAuth(username, password string)
@gopherbot gopherbot added this to the Proposal milestone Sep 20, 2022
@shalev67
Copy link
Author

The implementation for this proposal can be found here #55131.

@seankhliao
Copy link
Member

How common does the need for this occur that it needs specialized API in net/http?
The client side in particular seems unconvincing as it can't be directly used outside of dialer implementations, adding API surface there may mislead users on how proxy connections should be setup.

cc @neild

@ianlancetaylor
Copy link
Contributor

CC @neild @bradfitz

@rsc
Copy link
Contributor

rsc commented Sep 28, 2022

As @seankhliao said, these helpers seem like they can be implemented as a separate package very easily. We only added BasicAuth etc because they came up so often. This doesn't seem like it comes up often enough.

@rsc
Copy link
Contributor

rsc commented Sep 28, 2022

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc
Copy link
Contributor

rsc commented Oct 6, 2022

Based on the discussion above, this proposal seems like a likely decline.
— rsc for the proposal review group

@rsc
Copy link
Contributor

rsc commented Oct 12, 2022

No change in consensus, so declined.
— rsc for the proposal review group

@rsc rsc closed this as completed Oct 12, 2022
@golang golang locked and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants