admin: passwd authentication can be made with team name or certificate ID

This commit is contained in:
nemunaire 2020-01-15 10:52:39 +01:00
parent 141c5dd33d
commit 546cae869b

View File

@ -135,11 +135,11 @@ func genHtpasswd(ssha bool) (ret string, err error) {
hash.Write([]byte(cert.Password)) hash.Write([]byte(cert.Password))
hash.Write([]byte(salt)) hash.Write([]byte(salt))
ret += fmt.Sprintf( passwdline := fmt.Sprintf(":{SSHA}%s\n",base64.StdEncoding.EncodeToString(append(hash.Sum(nil), salt...)))
"%s:{SSHA}%s\n",
strings.ToLower(team.Name), ret += strings.ToLower(team.Name) + passwdline
base64.StdEncoding.EncodeToString(append(hash.Sum(nil), salt...)), ret += fmt.Sprintf("%0[2]*[1]x", cert.Id, int(math.Ceil(math.Log2(float64(cert.Id))/8)*2)) + passwdline
) ret += fmt.Sprintf("%0[2]*[1]X", cert.Id, int(math.Ceil(math.Log2(float64(cert.Id))/8)*2)) + passwdline
} else { } else {
salt32 := base32.StdEncoding.EncodeToString(salt) salt32 := base32.StdEncoding.EncodeToString(salt)
ret += fmt.Sprintf( ret += fmt.Sprintf(