Support AWS Signature V2 for Mattermost for S3 storage. (#6462)

Certain S3 compatible servers only use Legacy Signature (AWS
Signature V2), current code only supports signature v4.

This PR adds facility to click a button on the UI to enable
legacy signature with S3 compatible servers.
Этот коммит содержится в:
Harshavardhana
2017-05-30 16:12:24 -07:00
коммит произвёл Corey Hulen
родитель d409c7c1c6
Коммит f520aa1f4d
8 изменённых файлов: 69 добавлений и 11 удалений

Просмотреть файл

@@ -626,13 +626,21 @@ func readTestFile(name string) ([]byte, error) {
}
}
func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool) (*s3.Client, error) {
if signV2 {
return s3.NewV2(endpoint, accessKey, secretKey, secure)
}
return s3.NewV4(endpoint, accessKey, secretKey, secure)
}
func cleanupTestFile(info *model.FileInfo) error {
if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint
accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId
secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey
secure := *utils.Cfg.FileSettings.AmazonS3SSL
s3Clnt, err := s3.New(endpoint, accessKey, secretKey, secure)
signV2 := *utils.Cfg.FileSettings.AmazonS3SignV2
s3Clnt, err := s3New(endpoint, accessKey, secretKey, secure, signV2)
if err != nil {
return err
}