mirror of
https://github.com/minio/minio.git
synced 2025-11-20 09:56:07 -05:00
browser: Handle proper login errors. (#3518)
Also additionally log the remote address. Fixes #3514
This commit is contained in:
@@ -294,6 +294,9 @@ type LoginRep struct {
|
||||
func (web *webAPIHandlers) Login(r *http.Request, args *LoginArgs, reply *LoginRep) error {
|
||||
token, err := authenticateWeb(args.Username, args.Password)
|
||||
if err != nil {
|
||||
// Make sure to log errors related to browser login,
|
||||
// for security and auditing reasons.
|
||||
errorIf(err, "Unable to login request from %s", r.RemoteAddr)
|
||||
return toJSONError(err)
|
||||
}
|
||||
|
||||
@@ -768,13 +771,30 @@ func toWebAPIError(err error) APIError {
|
||||
HTTPStatusCode: http.StatusForbidden,
|
||||
Description: err.Error(),
|
||||
}
|
||||
}
|
||||
if err == errServerNotInitialized {
|
||||
} else if err == errServerNotInitialized {
|
||||
return APIError{
|
||||
Code: "XMinioServerNotInitialized",
|
||||
HTTPStatusCode: http.StatusServiceUnavailable,
|
||||
Description: err.Error(),
|
||||
}
|
||||
} else if err == errInvalidAccessKeyLength {
|
||||
return APIError{
|
||||
Code: "AccessDenied",
|
||||
HTTPStatusCode: http.StatusForbidden,
|
||||
Description: err.Error(),
|
||||
}
|
||||
} else if err == errInvalidSecretKeyLength {
|
||||
return APIError{
|
||||
Code: "AccessDenied",
|
||||
HTTPStatusCode: http.StatusForbidden,
|
||||
Description: err.Error(),
|
||||
}
|
||||
} else if err == errInvalidAccessKeyID {
|
||||
return APIError{
|
||||
Code: "AccessDenied",
|
||||
HTTPStatusCode: http.StatusForbidden,
|
||||
Description: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
// Convert error type to api error code.
|
||||
|
||||
Reference in New Issue
Block a user