mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
normalize LDAP auth HTTP responses (#21282)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
|
||||
"github.com/hashicorp/vault/sdk/framework"
|
||||
"github.com/hashicorp/vault/sdk/helper/ldaputil"
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
@@ -96,7 +97,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(errUserBindFailed), nil, nil
|
||||
return "", nil, logical.ErrorResponse(errUserBindFailed), nil, logical.ErrInvalidCredentials
|
||||
}
|
||||
|
||||
if b.Logger().IsDebug() {
|
||||
|
||||
@@ -83,17 +83,8 @@ func (b *backend) pathLogin(ctx context.Context, req *logical.Request, d *framew
|
||||
password := d.Get("password").(string)
|
||||
|
||||
effectiveUsername, policies, resp, groupNames, err := b.Login(ctx, req, username, password, cfg.UsernameAsAlias)
|
||||
// Handle an internal error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp != nil {
|
||||
// Handle a logical error
|
||||
if resp.IsError() {
|
||||
return resp, nil
|
||||
}
|
||||
} else {
|
||||
resp = &logical.Response{}
|
||||
if err != nil || (resp != nil && resp.IsError()) {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
auth := &logical.Auth{
|
||||
|
||||
3
changelog/21282.txt
Normal file
3
changelog/21282.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:change
|
||||
auth/ldap: Normalize HTTP response codes when invalid credentials are provided
|
||||
```
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
"github.com/hashicorp/go-sockaddr"
|
||||
"github.com/hashicorp/go-uuid"
|
||||
uberAtomic "go.uber.org/atomic"
|
||||
|
||||
"github.com/hashicorp/vault/command/server"
|
||||
"github.com/hashicorp/vault/helper/identity"
|
||||
"github.com/hashicorp/vault/helper/identity/mfa"
|
||||
@@ -36,7 +38,6 @@ import (
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
"github.com/hashicorp/vault/vault/quotas"
|
||||
"github.com/hashicorp/vault/vault/tokens"
|
||||
uberAtomic "go.uber.org/atomic"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -1406,7 +1407,7 @@ func (c *Core) handleLoginRequest(ctx context.Context, req *logical.Request) (re
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
return nil, nil, resp.Error()
|
||||
return resp, nil, routeErr
|
||||
}
|
||||
|
||||
if resp != nil {
|
||||
|
||||
Reference in New Issue
Block a user