Skip to content

Commit

Permalink
Handle Invalid User error coming from madmin (#314)
Browse files Browse the repository at this point in the history
Right now we display `Internal Server Error` when invalid credentials are presneted, this makes it so we only present `Unauthorized`
  • Loading branch information
dvaldivia committed Oct 6, 2020
1 parent 7166717 commit 6d8f1c4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions restapi/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/go-openapi/swag"
"github.com/minio/console/models"
"github.com/minio/minio/pkg/madmin"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
)

Expand Down Expand Up @@ -86,6 +87,11 @@ func prepareError(err ...error) *models.Error {
errorCode = 401
errorMessage = errorGenericInvalidSession.Error()
}
// console invalid session error
if madmin.ToErrorResponse(err[0]).Code == "XMinioAdminNoSuchUser" {
errorCode = 401
errorMessage = errorGenericInvalidSession.Error()
}
// if we received a second error take that as friendly message but dont override the code
if len(err) > 1 && err[1] != nil {
log.Print("friendly error: ", err[1].Error())
Expand Down

0 comments on commit 6d8f1c4

Please sign in to comment.