Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
7f6b35e769
|
@@ -153,15 +153,15 @@ func VerifyUser(file, user, passwd string) error {
|
|||||||
|
|
||||||
// Verify will check if the given user and password are matching
|
// Verify will check if the given user and password are matching
|
||||||
// with the given Passwd object content
|
// with the given Passwd object content
|
||||||
func (pp *Passwds) Verify(user, passwd string) error {
|
func (pp Passwds) Verify(user, passwd string) error {
|
||||||
if _, ok := (*pp)[user]; !ok {
|
if _, ok := pp[user]; !ok {
|
||||||
return fmt.Errorf("user %s does not exist", user)
|
return fmt.Errorf("user %s does not exist", user)
|
||||||
}
|
}
|
||||||
alg, err := identifyHash((*pp)[user])
|
alg, err := identifyHash(pp[user])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot identify algo %v", alg)
|
return fmt.Errorf("cannot identify algo %v", alg)
|
||||||
}
|
}
|
||||||
return verifyPass(passwd, (*pp)[user], alg)
|
return verifyPass(passwd, pp[user], alg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyPass(pass, hash string, alg HashAlgorithm) error {
|
func verifyPass(pass, hash string, alg HashAlgorithm) error {
|
||||||
@@ -235,9 +235,9 @@ func verifySSHA(password, hashedPassword string) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (pp *Passwds) toByte() []byte {
|
func (pp Passwds) toByte() []byte {
|
||||||
pass := []byte{}
|
pass := []byte{}
|
||||||
for name, hash := range *pp {
|
for name, hash := range pp {
|
||||||
pass = append(pass, []byte(name+":"+hash+"\n")...)
|
pass = append(pass, []byte(name+":"+hash+"\n")...)
|
||||||
}
|
}
|
||||||
return pass
|
return pass
|
||||||
|
|||||||
Reference in New Issue
Block a user