Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (r *Request) SetBasicAuth(username, password string) {
- 507 s := username + ":" + password
- 508 r.Header.Set("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(s)))
- 509 }
- //This is in the standard lib, printed it for you. I then call this on the daemon end.
- username, password := decode(request.Header.Get("Authorization"))
- //which calls this next function
- func decode(tmpAuth string) (username string, password string) {
- tmpAuthArray := strings.Split(tmpAuth, " ")
- authValues , error := base64.StdEncoding.DecodeString(tmpAuthArray[1])
- printError("ERROR: Failed to decode encoded auth settings in allocate list request.", error)
- authValuesArray := strings.Split(string(authValues), ":")
- username = authValuesArray[0]
- password = authValuesArray[1]
- return
- }
Add Comment
Please, Sign In to add comment