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

Backport of Improve Error Handling for Missing Credentials in AppRole and UserPass into release/1.17.x #28464

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion builtin/credential/approle/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (b *backend) pathLoginUpdate(ctx context.Context, req *logical.Request, dat
// RoleID must be supplied during every login
roleID := strings.TrimSpace(data.Get("role_id").(string))
if roleID == "" {
return logical.ErrorResponse("missing role_id"), nil
return nil, logical.ErrInvalidCredentials
}

// Look for the storage entry that maps the roleID to role
Expand Down
2 changes: 1 addition & 1 deletion builtin/credential/userpass/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (b *backend) pathLogin(ctx context.Context, req *logical.Request, d *framew

password := d.Get("password").(string)
if password == "" {
return nil, fmt.Errorf("missing password")
return nil, logical.ErrInvalidCredentials
}

// Get the user and validate auth
Expand Down
3 changes: 3 additions & 0 deletions changelog/28441.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
auth: Updated error handling for missing login credentials in AppRole and UserPass auth methods to return a 400 error instead of a 500 error.
```
2 changes: 1 addition & 1 deletion vault/external_tests/delegated_auth/delegated_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func TestDelegatedAuth(t *testing.T) {
path: "login",
username: "allowed-est",
password: "",
errorContains: "missing password",
errorContains: "invalid credentials",
},
{
name: "bad-path-within-delegated-auth-error",
Expand Down
Loading