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

Comments

Projects
None yet
4 participants
@mlowicki
Copy link

commented Oct 18, 2017

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

@gopherbot gopherbot added the Proposal label Oct 18, 2017

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Oct 18, 2017

@tombergan

This comment has been minimized.

Copy link
Contributor

commented Oct 18, 2017

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.

@tombergan tombergan closed this Oct 18, 2017

@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.
You can’t perform that action at this time.