From a568c3470552997130a64ad9d6241f57b690319a Mon Sep 17 00:00:00 2001 From: Fortune Ngwenya Date: Thu, 28 Sep 2023 12:04:37 +0200 Subject: [PATCH] Allow User to specify signature version --- README.md | 2 +- main.go | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 761038c..6892617 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The application can be configured with the following environment variables: - `SECRET_ACCESS_KEY`: Your S3 secret access key (required) (works only if `USE_IAM` is `false`) - `USE_SSL`: Whether your S3 server uses SSL or not (defaults to `true`) - `SKIP_SSL_VERIFICATION`: Whether the HTTP client should skip SSL verification (defaults to `false`) -- `SIGNATURE_VERSION`: Signature version (defaults to `V4`; valid values are `V2, V4, V4Streaming, Anonymous`) +- `SIGNATURE_TYPE`: Signature type (defaults to `V4`; valid values are `V2, V4, V4Streaming, Anonymous`) - `PORT`: The port the s3manager app should listen on (defaults to `8080`) - `ALLOW_DELETE`: Enable buttons to delete objects (defaults to `true`) - `FORCE_DOWNLOAD`: Add response headers for object downloading instead of opening in a new tab (defaults to `true`) diff --git a/main.go b/main.go index f6caa62..3dfd450 100644 --- a/main.go +++ b/main.go @@ -35,7 +35,7 @@ type configuration struct { ForceDownload bool UseSSL bool SkipSSLVerification bool - SignatureVersion string + SignatureType string ListRecursive bool Port string Timeout int32 @@ -81,8 +81,8 @@ func parseConfiguration() configuration { viper.SetDefault("SKIP_SSL_VERIFICATION", false) skipSSLVerification := viper.GetBool("SKIP_SSL_VERIFICATION") - viper.SetDefault("SIGNATURE_VERSION", "V4") - signatureVersion := viper.GetString("SIGNATURE_VERSION") + viper.SetDefault("SIGNATURE_TYPE", "V4") + signatureType := viper.GetString("SIGNATURE_TYPE") listRecursive := viper.GetBool("LIST_RECURSIVE") @@ -109,7 +109,7 @@ func parseConfiguration() configuration { ForceDownload: forceDownload, UseSSL: useSSL, SkipSSLVerification: skipSSLVerification, - SignatureVersion: signatureVersion, + SignatureType: signatureType, ListRecursive: listRecursive, Port: port, Timeout: timeout, @@ -142,22 +142,22 @@ func main() { if configuration.UseIam { opts.Creds = credentials.NewIAM(configuration.IamEndpoint) } else { - var signatureVersion credentials.SignatureType + var signatureType credentials.SignatureType - switch configuration.SignatureVersion { + switch configuration.SignatureType { case "V2": - signatureVersion = credentials.SignatureV2 + signatureType = credentials.SignatureV2 case "V4": - signatureVersion = credentials.SignatureV4 + signatureType = credentials.SignatureV4 case "V4Streaming": - signatureVersion = credentials.SignatureV4Streaming + signatureType = credentials.SignatureV4Streaming case "Anonymous": - signatureVersion = credentials.SignatureAnonymous + signatureType = credentials.SignatureAnonymous default: - log.Fatalf("Invalid Signature Version: %s", configuration.SignatureVersion) + log.Fatalf("Invalid SIGNATURE_TYPE: %s", configuration.SignatureType) } - opts.Creds = credentials.NewStatic(configuration.AccessKeyID, configuration.SecretAccessKey, "", signatureVersion) + opts.Creds = credentials.NewStatic(configuration.AccessKeyID, configuration.SecretAccessKey, "", signatureType) } if configuration.Region != "" {