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: Export parseBasicAuth #22332

Closed
mlowicki opened this issue Oct 18, 2017 · 2 comments
Closed

proposal: net/http: Export parseBasicAuth #22332

mlowicki opened this issue Oct 18, 2017 · 2 comments

Comments

@mlowicki
Copy link
Contributor

Currently parseBasicAuth is not exported and used only by BasicAuth function which always uses "Authorization" header. Proxy server can use something like "Proxy-Authorization" or "XXX-Proxy-Authorization" headers and currently it's not possible to reuse parseBasicAuth to parse basic auth payload there. My proposal would be to simply export this function so proxy servers could apply it like:

    auth := r.Header.Get("XXX-Proxy-Authorization")
    if auth == "" {
        http.Error(w, "", http.StatusProxyAuthRequired)
        return
    } 
    username, password, ok := http.ParseBasicAuth(auth)
@odeke-em odeke-em changed the title Export parseBasicAuth from http package proposal: net/http: Export parseBasicAuth Oct 18, 2017
@gopherbot gopherbot added this to the Proposal milestone Oct 18, 2017
@ianlancetaylor
Copy link
Contributor

CC @tombergan

@tombergan
Copy link
Contributor

parseBasicAuth is trivial: trim "Basic ", decode base64, split on ":". I do not think it's worth expanding the API just so that custom headers can reuse those same 14 lines of code.

@golang golang locked and limited conversation to collaborators Oct 18, 2018
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

4 participants