check whether must use v4 auth in specific aws region
Signed-off-by: sakeven <jc5930@sina.cn>
This commit is contained in:
parent
fb0bebc4b6
commit
72bdf0e320
1 changed files with 13 additions and 4 deletions
|
@ -266,10 +266,8 @@ func New(params DriverParameters) (*Driver, error) {
|
||||||
|
|
||||||
if params.V4Auth {
|
if params.V4Auth {
|
||||||
s3obj.Signature = aws.V4Signature
|
s3obj.Signature = aws.V4Signature
|
||||||
} else {
|
} else if mustV4Auth(params.Region.Name) {
|
||||||
if params.Region.Name == "eu-central-1" {
|
return nil, fmt.Errorf("The %s region only works with v4 authentication", params.Region.Name)
|
||||||
return nil, fmt.Errorf("The eu-central-1 region only works with v4 authentication")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bucket := s3obj.Bucket(params.Bucket)
|
bucket := s3obj.Bucket(params.Bucket)
|
||||||
|
@ -573,6 +571,17 @@ func getPermissions() s3.ACL {
|
||||||
return s3.Private
|
return s3.Private
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mustV4Auth checks whether must use v4 auth in specific region.
|
||||||
|
// Please see documentation at http://docs.aws.amazon.com/general/latest/gr/signature-version-2.html
|
||||||
|
func mustV4Auth(region string) bool {
|
||||||
|
switch region {
|
||||||
|
case "eu-central-1", "cn-north-1", "us-east-2",
|
||||||
|
"ca-central-1", "ap-south-1", "ap-northeast-2", "eu-west-2":
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (d *driver) getContentType() string {
|
func (d *driver) getContentType() string {
|
||||||
return "application/octet-stream"
|
return "application/octet-stream"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue