SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
s3tables: refactor handleDeleteTableBucket to use strongly typed AuthError
Chris Luf5d71008d725
diff --git a/weed/s3api/s3tables/handler_bucket_get_list_delete.go b/weed/s3api/s3tables/handler_bucket_get_list_delete.goindex cbb9596a03..fa06f94baf 100644--- a/weed/s3api/s3tables/handler_bucket_get_list_delete.go+++ b/weed/s3api/s3tables/handler_bucket_get_list_delete.go@@ -239,8 +239,8 @@ func (h *S3TablesHandler) handleDeleteTableBucket(w http.ResponseWriter, r *http// 2. Check ownershipprincipal := h.getPrincipalFromRequest(r)- if principal != metadata.OwnerAccountID {- return fmt.Errorf("access denied: principal %s does not own bucket %s", principal, bucketName)+ if !CanDeleteTableBucket(principal, metadata.OwnerAccountID) {+ return NewAuthError("DeleteTableBucket", principal, fmt.Sprintf("not authorized to delete bucket %s", bucketName))}// 3. Check if bucket is empty@@ -272,7 +272,7 @@ func (h *S3TablesHandler) handleDeleteTableBucket(w http.ResponseWriter, r *httpif err != nil {if errors.Is(err, filer_pb.ErrNotFound) {h.writeError(w, http.StatusNotFound, ErrCodeNoSuchBucket, fmt.Sprintf("table bucket %s not found", bucketName))- } else if strings.Contains(err.Error(), "access denied") {+ } else if isAuthError(err) {h.writeError(w, http.StatusForbidden, ErrCodeAccessDenied, err.Error())} else {h.writeError(w, http.StatusInternalServerError, ErrCodeInternalError, fmt.Sprintf("failed to delete table bucket: %v", err))