Skip to content

Commit

Permalink
Improve consistency in error messages (#10537) (#10539)
Browse files Browse the repository at this point in the history
* Improve consistency in error messages

* add changelog entry
  • Loading branch information
catsby authored Dec 11, 2020
1 parent fc2997e commit 5f8c7d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions builtin/credential/ldap/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)

const errUserBindFailed = `ldap operation failed: failed to bind as user`

func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
if err := b.Setup(ctx, conf); err != nil {
Expand Down Expand Up @@ -93,7 +95,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
if b.Logger().IsDebug() {
b.Logger().Debug("error getting user bind DN", "error", err)
}
return nil, logical.ErrorResponse("ldap operation failed: unable to retrieve user bind DN"), nil, nil
return nil, logical.ErrorResponse(errUserBindFailed), nil, nil
}

if b.Logger().IsDebug() {
Expand All @@ -110,7 +112,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
if b.Logger().IsDebug() {
b.Logger().Debug("ldap bind failed", "error", err)
}
return nil, logical.ErrorResponse("ldap operation failed: failed to bind as user"), nil, nil
return nil, logical.ErrorResponse(errUserBindFailed), nil, nil
}

// We re-bind to the BindDN if it's defined because we assume
Expand Down
3 changes: 3 additions & 0 deletions changelog/10537.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
auth/ldap: Improve consistency in error messages
```

0 comments on commit 5f8c7d2

Please sign in to comment.