Skip to content

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.

s3tables: Consolidate getPrincipalFromRequest and getAccountID into single method

Chris Lu41e799b4e027
diff --git a/weed/s3api/s3tables/handler.go b/weed/s3api/s3tables/handler.go
index 088351d3bd..982b78b281 100644
--- a/weed/s3api/s3tables/handler.go
+++ b/weed/s3api/s3tables/handler.go
@@ -157,19 +157,9 @@ func (h *S3TablesHandler) HandleRequest(w http.ResponseWriter, r *http.Request,
// Principal/authorization helpers
-func (h *S3TablesHandler) getPrincipalFromRequest(r *http.Request) string {
- // Prefer the authenticated account ID from the request header. This is the same
- // identifier used as the "owner" in permission checks, so keeping them aligned
- // avoids mismatches (e.g. username vs. account ID) when IAM is enabled.
- if accountID := r.Header.Get(s3_constants.AmzAccountId); accountID != "" {
- return accountID
- }
-
- // Default to handler's configured account ID
- return h.accountID
-}
-
-// getAccountID returns the authenticated account ID from the request or the handler's default
+// getAccountID returns the authenticated account ID from the request or the handler's default.
+// This is also used as the principal for permission checks, ensuring alignment between
+// the caller identity and ownership verification when IAM is enabled.
func (h *S3TablesHandler) getAccountID(r *http.Request) string {
if accountID := r.Header.Get(s3_constants.AmzAccountId); accountID != "" {
return accountID