Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Return AuthenticationFailedError when password is not OK #3182

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions services/users/set_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import (
)

var (
NameReservedError = errors.New("Username is reserved")
NameReservedError = errors.New("Username is reserved")
AuthenticationFailedError = errors.New("Authentication Failed")
)

// Update the user's password.
Expand Down Expand Up @@ -143,6 +144,8 @@ func verifyPassword(self *api_proto.VelociraptorUser, password string) bool {
return subtle.ConstantTimeCompare(hash[:], self.PasswordHash) == 1
}

// Verifies the username's password is ok. If the password is not OK
// returns an AuthenticationFailedError too.
func (self *UserManager) VerifyPassword(
ctx context.Context,
principal, username string,
Expand All @@ -153,5 +156,10 @@ func (self *UserManager) VerifyPassword(
return false, err
}

return verifyPassword(user_record, password), nil
ok := verifyPassword(user_record, password)
if !ok {
return ok, AuthenticationFailedError
}

return true, nil
}