diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2017-09-05 15:24:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-05 15:24:21 -0400 |
commit | 09f8267751c71bdb6d8ba2757a1e4ffe62ccf5c3 (patch) | |
tree | d540c42e07195d62c8555c05ca5e57becf5542a6 | |
parent | cc289d70610ada2797c7a07dce013fd4d89bcc10 (diff) | |
download | chat-09f8267751c71bdb6d8ba2757a1e4ffe62ccf5c3.tar.gz chat-09f8267751c71bdb6d8ba2757a1e4ffe62ccf5c3.tar.bz2 chat-09f8267751c71bdb6d8ba2757a1e4ffe62ccf5c3.zip |
PLT-7517 Added setting to enable tracing of Amazon S3 connections (#7349)
* PLT-7517 Added setting to enable tracing of Amazon S3 connections
* Removed unnecessary placeholders on boolean settings
* Added AmazonS3Trace to diagnostics
* Updated AmazonS3Trace setting name in system console
* Removing extra colon
-rw-r--r-- | app/diagnostics.go | 1 | ||||
-rw-r--r-- | config/default.json | 3 | ||||
-rw-r--r-- | model/config.go | 6 | ||||
-rw-r--r-- | utils/file.go | 12 | ||||
-rw-r--r-- | webapp/components/admin_console/storage_settings.jsx | 24 | ||||
-rwxr-xr-x | webapp/i18n/en.json | 4 |
6 files changed, 43 insertions, 7 deletions
diff --git a/app/diagnostics.go b/app/diagnostics.go index 62dcc0b64..713d8aa26 100644 --- a/app/diagnostics.go +++ b/app/diagnostics.go @@ -290,6 +290,7 @@ func trackConfig() { "amazon_s3_ssl": *utils.Cfg.FileSettings.AmazonS3SSL, "amazon_s3_sse": *utils.Cfg.FileSettings.AmazonS3SSE, "amazon_s3_signv2": *utils.Cfg.FileSettings.AmazonS3SignV2, + "amazon_s3_trace": *utils.Cfg.FileSettings.AmazonS3Trace, "max_file_size": *utils.Cfg.FileSettings.MaxFileSize, "enable_file_attachments": *utils.Cfg.FileSettings.EnableFileAttachments, "enable_mobile_upload": *utils.Cfg.FileSettings.EnableMobileUpload, diff --git a/config/default.json b/config/default.json index 59bcf8bc6..50bf7b32b 100644 --- a/config/default.json +++ b/config/default.json @@ -131,7 +131,8 @@ "AmazonS3Endpoint": "s3.amazonaws.com", "AmazonS3SSL": true, "AmazonS3SignV2": false, - "AmazonS3SSE": false + "AmazonS3SSE": false, + "AmazonS3Trace": false }, "EmailSettings": { "EnableSignUpWithEmail": true, diff --git a/model/config.go b/model/config.go index 85181edd9..311a43261 100644 --- a/model/config.go +++ b/model/config.go @@ -272,6 +272,7 @@ type FileSettings struct { AmazonS3SSL *bool AmazonS3SignV2 *bool AmazonS3SSE *bool + AmazonS3Trace *bool } type EmailSettings struct { @@ -607,6 +608,11 @@ func (o *Config) SetDefaults() { *o.FileSettings.AmazonS3SSE = false // Not Encrypted by default. } + if o.FileSettings.AmazonS3Trace == nil { + o.FileSettings.AmazonS3Trace = new(bool) + *o.FileSettings.AmazonS3Trace = false + } + if o.FileSettings.EnableFileAttachments == nil { o.FileSettings.EnableFileAttachments = new(bool) *o.FileSettings.EnableFileAttachments = true diff --git a/utils/file.go b/utils/file.go index 0ba132b09..19fa335c4 100644 --- a/utils/file.go +++ b/utils/file.go @@ -33,7 +33,17 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi } else { creds = credentials.NewStatic(accessKey, secretKey, "", credentials.SignatureV4) } - return s3.NewWithCredentials(endpoint, creds, secure, region) + + s3Clnt, err := s3.NewWithCredentials(endpoint, creds, secure, region) + if err != nil { + return nil, err + } + + if *Cfg.FileSettings.AmazonS3Trace { + s3Clnt.TraceOn(os.Stdout) + } + + return s3Clnt, nil } func TestFileConnection() *model.AppError { diff --git a/webapp/components/admin_console/storage_settings.jsx b/webapp/components/admin_console/storage_settings.jsx index b591758b1..4b20a8b93 100644 --- a/webapp/components/admin_console/storage_settings.jsx +++ b/webapp/components/admin_console/storage_settings.jsx @@ -37,6 +37,7 @@ export default class StorageSettings extends AdminSettings { config.FileSettings.AmazonS3Endpoint = this.state.amazonS3Endpoint; config.FileSettings.AmazonS3SSL = this.state.amazonS3SSL; config.FileSettings.AmazonS3SSE = this.state.amazonS3SSE; + config.FileSettings.AmazonS3Trace = this.state.amazonS3Trace; return config; } @@ -54,7 +55,8 @@ export default class StorageSettings extends AdminSettings { amazonS3Bucket: config.FileSettings.AmazonS3Bucket, amazonS3Endpoint: config.FileSettings.AmazonS3Endpoint, amazonS3SSL: config.FileSettings.AmazonS3SSL, - amazonS3SSE: config.FileSettings.AmazonS3SSE + amazonS3SSE: config.FileSettings.AmazonS3SSE, + amazonS3Trace: config.FileSettings.AmazonS3Trace }; } @@ -125,7 +127,6 @@ export default class StorageSettings extends AdminSettings { defaultMessage='Enable Server-Side Encryption for Amazon S3:' /> } - placeholder={Utils.localizeMessage('admin.image.amazonS3SSEExample', 'Ex "false"')} helpText={ <FormattedHTMLMessage id='admin.image.amazonS3SSEDescription' @@ -267,7 +268,6 @@ export default class StorageSettings extends AdminSettings { defaultMessage='Enable Secure Amazon S3 Connections:' /> } - placeholder={Utils.localizeMessage('admin.image.amazonS3SSLExample', 'Ex "true"')} helpText={ <FormattedMessage id='admin.image.amazonS3SSLDescription' @@ -280,6 +280,24 @@ export default class StorageSettings extends AdminSettings { /> {amazonSSEComp} <BooleanSetting + id='amazonS3Trace' + label={ + <FormattedMessage + id='admin.image.amazonS3TraceTitle' + defaultMessage='Enable Amazon S3 Debugging:' + /> + } + helpText={ + <FormattedMessage + id='admin.image.amazonS3TraceDescription' + defaultMessage='(Development Mode) When true, log additional debugging information to the system logs.' + /> + } + value={this.state.amazonS3Trace} + onChange={this.handleChange} + disabled={this.state.driverName !== DRIVER_S3} + /> + <BooleanSetting id='enableFileAttachments' label={ <FormattedMessage diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index 635c619a3..f111c5dd5 100755 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -479,14 +479,14 @@ "admin.image.amazonS3RegionExample": "E.g.: \"us-east-1\"", "admin.image.amazonS3RegionTitle": "Amazon S3 Region:", "admin.image.amazonS3SSEDescription": "When true, encrypt files in Amazon S3 using server-side encryption with Amazon S3-managed keys. See <a href=\"https://about.mattermost.com/default-server-side-encryption\">documentation</a> to learn more.", - "admin.image.amazonS3SSEExample": "E.g.: \"false\"", "admin.image.amazonS3SSETitle": "Enable Server-Side Encryption for Amazon S3:", "admin.image.amazonS3SSLDescription": "When false, allow insecure connections to Amazon S3. Defaults to secure connections only.", - "admin.image.amazonS3SSLExample": "E.g.: \"true\"", "admin.image.amazonS3SSLTitle": "Enable Secure Amazon S3 Connections:", "admin.image.amazonS3SecretDescription": "Obtain this credential from your Amazon EC2 administrator.", "admin.image.amazonS3SecretExample": "E.g.: \"jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY\"", "admin.image.amazonS3SecretTitle": "Amazon S3 Secret Access Key:", + "admin.image.amazonS3TraceDescription": "(Development Mode) When true, log additional debugging information to the system logs.", + "admin.image.amazonS3TraceTitle": "Enable Amazon S3 Debugging:", "admin.image.localDescription": "Directory to which files and images are written. If blank, defaults to ./data/.", "admin.image.localExample": "E.g.: \"./data/\"", "admin.image.localTitle": "Local Storage Directory:", |