From 0674fa43ff70129116474c0682a5d7ab586d400d Mon Sep 17 00:00:00 2001 From: Andreas Kohn Date: Thu, 19 Jan 2017 20:31:51 +0100 Subject: [PATCH] Handle the region for GetBucketLocation and PutBucket properly (#3596) This adjusts the code for these two handlers to match the logic in ListBucketHandler. Fixes #3595 --- cmd/bucket-handlers.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index aadd99bb4..95227f4af 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -100,7 +100,12 @@ func (api objectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r * return } - if s3Error := checkRequestAuthType(r, bucket, "s3:GetBucketLocation", globalMinioDefaultRegion); s3Error != ErrNone { + s3Error := checkRequestAuthType(r, bucket, "s3:GetBucketLocation", globalMinioDefaultRegion) + if s3Error == ErrInvalidRegion { + // Clients like boto3 send getBucketLocation() call signed with region that is configured. + s3Error = checkRequestAuthType(r, "", "s3:GetBucketLocation", serverConfig.GetRegion()) + } + if s3Error != ErrNone { writeErrorResponse(w, s3Error, r.URL) return } @@ -334,7 +339,12 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req } // PutBucket does not have any bucket action. - if s3Error := checkRequestAuthType(r, "", "", globalMinioDefaultRegion); s3Error != ErrNone { + s3Error := checkRequestAuthType(r, "", "", globalMinioDefaultRegion) + if s3Error == ErrInvalidRegion { + // Clients like boto3 send putBucket() call signed with region that is configured. + s3Error = checkRequestAuthType(r, "", "", serverConfig.GetRegion()) + } + if s3Error != ErrNone { writeErrorResponse(w, s3Error, r.URL) return }