Skip to content

Commit

Permalink
Normalize userpass errors around bad user/pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed Mar 16, 2016
1 parent 33c2641 commit d887ecb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builtin/credential/userpass/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ func (b *backend) pathLogin(
return nil, err
}
if user == nil {
return logical.ErrorResponse("username does not exist"), nil
return logical.ErrorResponse("invalid username or password"), nil
}

// Check for a password match. Check for a hash collision for Vault 0.2+,
// but handle the older legacy passwords with a constant time comparison.
passwordBytes := []byte(password)
if user.PasswordHash != nil {
if err := bcrypt.CompareHashAndPassword(user.PasswordHash, passwordBytes); err != nil {
return logical.ErrorResponse("unknown username or password"), nil
return logical.ErrorResponse("invalid username or password"), nil
}
} else {
if subtle.ConstantTimeCompare([]byte(user.Password), passwordBytes) != 1 {
return logical.ErrorResponse("unknown username or password"), nil
return logical.ErrorResponse("invalid username or password"), nil
}
}

Expand Down

0 comments on commit d887ecb

Please sign in to comment.