using passed in basic auth to avoid conficts, if given

This commit is contained in:
Jan Halfar 2017-07-11 14:24:14 +02:00
parent 929ed74872
commit 7ccda9d1be

View File

@ -79,6 +79,14 @@ func makeFoomo(foomoDir string, runMode string, address string, init bool) (f *F
}
func (f *Foomo) setupBasicAuthCredentials() error {
if f.URL.User != nil {
f.basicAuthCredentials.user = f.URL.User.Username()
password, passwordOK := f.URL.User.Password()
if passwordOK {
f.basicAuthCredentials.password = password
return nil
}
}
f.basicAuthCredentials.user = "gofoomo"
f.basicAuthCredentials.password = makeToken(50)
return htpasswd.SetPassword(f.GetBasicAuthFilename("default"), f.basicAuthCredentials.user, f.basicAuthCredentials.password, htpasswd.HashBCrypt)