Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c9a00a3820
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (24 sloc) 0.581 kb
package steno
import (
"encoding/base64"
"net/http"
"strings"
)
func checkAuth(req *http.Request, user string, password string) bool {
if user == "" && password == "" {
return true
}
authParts := strings.Split(req.Header.Get("Authorization"), " ")
if len(authParts) != 2 || authParts[0] != "Basic" {
return false
}
code, err := base64.StdEncoding.DecodeString(authParts[1])
if err != nil {
return false
}
userPass := strings.Split(string(code), ":")
if len(userPass) != 2 || userPass[0] != user || userPass[1] != password {
return false
}
return true
}
Jump to Line
Something went wrong with that request. Please try again.