MCPcopy
hub / github.com/perkeep/perkeep / newUserPassAuth

Function newUserPassAuth

pkg/auth/auth.go:125–146  ·  view source on GitHub ↗
(arg string)

Source from the content-addressed store, hash-verified

123}
124
125func 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
148func newBasicAuth(arg string) (AuthMode, error) {
149 pieces := strings.Split(arg, ":")

Callers 1

TestEmptyPasswordsFunction · 0.85

Calls 1

HasPrefixMethod · 0.80

Tested by 1

TestEmptyPasswordsFunction · 0.68