| 123 | } |
| 124 | |
| 125 | func newUserPassAuth(arg string) (AuthMode, error) { |
| 126 | pieces := strings.Split(arg, ":") |
| 127 | if len(pieces) < 2 { |
| 128 | return nil, fmt.Errorf("Wrong userpass auth string; needs to be \"user:password\"") |
| 129 | } |
| 130 | username := pieces[0] |
| 131 | password := pieces[1] |
| 132 | mode := &UserPass{Username: username, Password: password} |
| 133 | for _, opt := range pieces[2:] { |
| 134 | switch { |
| 135 | case opt == "+localhost": |
| 136 | mode.OrLocalhost = true |
| 137 | case strings.HasPrefix(opt, "vivify="): |
| 138 | // optional vivify mode password: "userpass:joe:ponies:vivify=rainbowdash" |
| 139 | vp := strings.Replace(opt, "vivify=", "", -1) |
| 140 | mode.VivifyPass = &vp |
| 141 | default: |
| 142 | return nil, fmt.Errorf("Unknown userpass option %q", opt) |
| 143 | } |
| 144 | } |
| 145 | return mode, nil |
| 146 | } |
| 147 | |
| 148 | func newBasicAuth(arg string) (AuthMode, error) { |
| 149 | pieces := strings.Split(arg, ":") |