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(salt))
ret += fmt.Sprintf(
"%s:{SSHA}%s\n",
strings.ToLower(team.Name),
base64.StdEncoding.EncodeToString(append(hash.Sum(nil), salt...)),
)
passwdline := fmt.Sprintf(":{SSHA}%s\n",base64.StdEncoding.EncodeToString(append(hash.Sum(nil), salt...)))
ret += strings.ToLower(team.Name) + passwdline
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 {
salt32 := base32.StdEncoding.EncodeToString(salt)
ret += fmt.Sprintf(