|
|
@ -294,6 +294,9 @@ type LoginRep struct { |
|
|
|
func (web *webAPIHandlers) Login(r *http.Request, args *LoginArgs, reply *LoginRep) error { |
|
|
|
func (web *webAPIHandlers) Login(r *http.Request, args *LoginArgs, reply *LoginRep) error { |
|
|
|
token, err := authenticateWeb(args.Username, args.Password) |
|
|
|
token, err := authenticateWeb(args.Username, args.Password) |
|
|
|
if err != nil { |
|
|
|
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) |
|
|
|
return toJSONError(err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -768,13 +771,30 @@ func toWebAPIError(err error) APIError { |
|
|
|
HTTPStatusCode: http.StatusForbidden, |
|
|
|
HTTPStatusCode: http.StatusForbidden, |
|
|
|
Description: err.Error(), |
|
|
|
Description: err.Error(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if err == errServerNotInitialized { |
|
|
|
if err == errServerNotInitialized { |
|
|
|
|
|
|
|
return APIError{ |
|
|
|
return APIError{ |
|
|
|
Code: "XMinioServerNotInitialized", |
|
|
|
Code: "XMinioServerNotInitialized", |
|
|
|
HTTPStatusCode: http.StatusServiceUnavailable, |
|
|
|
HTTPStatusCode: http.StatusServiceUnavailable, |
|
|
|
Description: err.Error(), |
|
|
|
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.
|
|
|
|
// Convert error type to api error code.
|
|
|
|