You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
odeke-em
changed the title
Export parseBasicAuth from http package
proposal: net/http: Export parseBasicAuth
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.
Currently
parseBasicAuth
is not exported and used only byBasicAuth
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 reuseparseBasicAuth
to parse basic auth payload there. My proposal would be to simply export this function so proxy servers could apply it like:The text was updated successfully, but these errors were encountered: