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

Open
shalev67 opened this issue Sep 20, 2022 · 5 comments
Open

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

shalev67 opened this issue Sep 20, 2022 · 5 comments
Labels
Milestone

Comments

@shalev67
Copy link

shalev67 commented Sep 20, 2022

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

shalev67 commented Sep 20, 2022

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

@seankhliao
Copy link
Member

seankhliao commented Sep 20, 2022

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

ianlancetaylor commented Sep 21, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Active
Development

No branches or pull requests

5 participants