diff --git a/cmd/gateway-handlers.go b/cmd/gateway-handlers.go index 269a3e31c..bce48a8dd 100644 --- a/cmd/gateway-handlers.go +++ b/cmd/gateway-handlers.go @@ -65,6 +65,12 @@ func (api gatewayAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Re writeErrorResponse(w, s3Error, r.URL) return } + case authTypeAnonymous: + // No verification needed for anonymous requests. + default: + // For all unknown auth types return error. + writeErrorResponse(w, ErrAccessDenied, r.URL) + return } getObjectInfo := objectAPI.GetObjectInfo @@ -239,10 +245,6 @@ func (api gatewayAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Re var objInfo ObjectInfo switch reqAuthType { - default: - // For all unknown auth types return error. - writeErrorResponse(w, ErrAccessDenied, r.URL) - return case authTypeAnonymous: // Create anonymous object. objInfo, err = objectAPI.AnonPutObject(bucket, object, size, r.Body, metadata, sha256sum) @@ -274,6 +276,10 @@ func (api gatewayAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Re } // Create object. objInfo, err = objectAPI.PutObject(bucket, object, size, r.Body, metadata, sha256sum) + default: + // For all unknown auth types return error. + writeErrorResponse(w, ErrAccessDenied, r.URL) + return } w.Header().Set("ETag", "\""+objInfo.MD5Sum+"\"") @@ -313,6 +319,12 @@ func (api gatewayAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.R writeErrorResponse(w, s3Error, r.URL) return } + case authTypeAnonymous: + // No verification needed for anonymous requests. + default: + // For all unknown auth types return error. + writeErrorResponse(w, ErrAccessDenied, r.URL) + return } getObjectInfo := objectAPI.GetObjectInfo @@ -721,6 +733,12 @@ func (api gatewayAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *htt writeErrorResponse(w, s3Error, r.URL) return } + case authTypeAnonymous: + // No verification needed for anonymous requests. + default: + // For all unknown auth types return error. + writeErrorResponse(w, ErrAccessDenied, r.URL) + return } // Extract all the litsObjectsV1 query params to their native values. @@ -785,6 +803,12 @@ func (api gatewayAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.R writeErrorResponse(w, s3Error, r.URL) return } + case authTypeAnonymous: + // No verification needed for anonymous requests. + default: + // For all unknown auth types return error. + writeErrorResponse(w, ErrAccessDenied, r.URL) + return } getBucketInfo := objectAPI.GetBucketInfo @@ -835,6 +859,12 @@ func (api gatewayAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r writeErrorResponse(w, s3Error, r.URL) return } + case authTypeAnonymous: + // No verification needed for anonymous requests. + default: + // For all unknown auth types return error. + writeErrorResponse(w, ErrAccessDenied, r.URL) + return } getBucketInfo := objectAPI.GetBucketInfo