fix: reject a ListBuckets bucket-region other than the gateway region
S3 never lists an empty result for another region: a valid region other than the endpoint's own gets 400 InvalidArgument, "Requests with bucket-region specified must be made to the corresponding regional endpoint", with no ArgumentValue. The gateway is a single regional endpoint, so it now does the same instead of clearing the listing. Match the region case-insensitively like S3, and check an empty bucket-region= too by looking for the query argument itself, since an empty value is not a valid AWS region either.
This commit is contained in:
1 parent
5d293b1316
commit
e1d2284906
7 files changed
+104
-56
No files matched your search
+11
-5
@@ -1155,11 +1155,17 @@ func ValidateLocationConstraint(constraint *string, region string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsValidBucketRegion checks a ListBuckets bucket-region value. The gateway
|
||||
// region is valid whatever its name, any other value has to be an AWS region
|
||||
// code.
|
||||
func IsValidBucketRegion(bucketRegion, region string) bool {
|
||||
return bucketRegion == region || awsRegionRegexp.MatchString(bucketRegion)
|
||||
// ValidateBucketRegion checks a ListBuckets bucket-region value. Every bucket
|
||||
// lives in the gateway region, so like an S3 regional endpoint the gateway
|
||||
// rejects any other region, matching it case-insensitively.
|
||||
func ValidateBucketRegion(bucketRegion, region string) error {
|
||||
if strings.EqualFold(bucketRegion, region) {
|
||||
return nil
|
||||
}
|
||||
if !awsRegionRegexp.MatchString(strings.ToLower(bucketRegion)) {
|
||||
return s3err.GetInvalidArgBucketRegion(bucketRegion)
|
||||
}
|
||||
return s3err.GetInvalidArgumentErr(s3err.InvalidArgBucketRegionEndpoint, "")
|
||||
}
|
||||
|
||||
// AwsChunkedEncoding is the coding a client announces when it frames a body in
|
||||
|
||||
Reference in new issue
Block a user