Allow User to specify signature version
This commit is contained in:
parent
13fbc77677
commit
a568c34705
2 changed files with 13 additions and 13 deletions
|
@ -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`)
|
||||
|
|
24
main.go
24
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 != "" {
|
||||
|
|
Loading…
Reference in a new issue