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

Return request unauthorized error on invalid password credentials #261

Merged
merged 2 commits into from
Apr 23, 2018
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 handler/oauth2/flow_resource_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (c *ResourceOwnerPasswordCredentialsGrantHandler) HandleTokenEndpointReques
if username == "" || password == "" {
return errors.WithStack(fosite.ErrInvalidRequest.WithDebug("Username or password missing"))
} else if err := c.ResourceOwnerPasswordCredentialsGrantStorage.Authenticate(ctx, username, password); errors.Cause(err) == fosite.ErrNotFound {
return errors.WithStack(fosite.ErrInvalidRequest.WithDebug(err.Error()))
return errors.WithStack(fosite.ErrRequestUnauthorized.WithDebug(err.Error()))
} else if err != nil {
return errors.WithStack(fosite.ErrServerError.WithDebug(err.Error()))
}
Expand Down
2 changes: 1 addition & 1 deletion handler/oauth2/flow_resource_owner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestResourceOwnerFlow_HandleTokenEndpointRequest(t *testing.T) {

store.EXPECT().Authenticate(nil, "peter", "pan").Return(fosite.ErrNotFound)
},
expectErr: fosite.ErrInvalidRequest,
expectErr: fosite.ErrRequestUnauthorized,
},
{
description: "should fail because because error on lookup",
Expand Down