s3tables: implement permission checking and authorization

- Add permissions.go with permission definitions and checks
- Define permissions for all 21 S3 Tables operations
- Add permission checking helper functions
- Add getPrincipalFromRequest to extract caller identity
- Implement access control in CreateTableBucket, GetTableBucket, DeleteTableBucket
- Return 403 Forbidden for unauthorized operations
- Only bucket owner can perform operations (extensible for future policies)
- Add AuthError type for authorization failures
This commit is contained in:
Chris Lu
2026-01-28 01:18:11 -08:00
parent 1b9c8b8614
commit fb0e12e985
4 changed files with 229 additions and 0 deletions

View File

@@ -140,6 +140,20 @@ func (h *S3TablesHandler) HandleRequest(w http.ResponseWriter, r *http.Request,
}
}
// Principal/authorization helpers
func (h *S3TablesHandler) getPrincipalFromRequest(r *http.Request) string {
// Extract principal from request headers
// This can be extended to parse AWS credentials, client certificates, etc.
principal := r.Header.Get("X-Amz-Principal")
if principal != "" {
return principal
}
// Default to account ID
return h.accountID
}
// Request/Response helpers
func (h *S3TablesHandler) readRequestBody(r *http.Request, v interface{}) error {