From c21ac802682b957786b79db4c2344f0662dd3d32 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 21 Oct 2016 00:07:24 +0100 Subject: [PATCH] Validate access/secret keys found in the config file and enhance invalid keys messages (#3017) --- cmd/main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index c3a028f83..7a2c770e5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -178,18 +178,18 @@ func Main() { accessKey := os.Getenv("MINIO_ACCESS_KEY") secretKey := os.Getenv("MINIO_SECRET_KEY") if accessKey != "" && secretKey != "" { - if !isValidAccessKey.MatchString(accessKey) { - fatalIf(errInvalidArgument, "Invalid access key.") - } - if !isValidSecretKey.MatchString(secretKey) { - fatalIf(errInvalidArgument, "Invalid secret key.") - } // Set new credentials. serverConfig.SetCredential(credential{ AccessKeyID: accessKey, SecretAccessKey: secretKey, }) } + if !isValidAccessKey.MatchString(serverConfig.GetCredential().AccessKeyID) { + fatalIf(errInvalidArgument, "Invalid access key. Accept only a string starting with a alphabetic and containing from 5 to 20 characters.") + } + if !isValidSecretKey.MatchString(serverConfig.GetCredential().SecretAccessKey) { + fatalIf(errInvalidArgument, "Invalid secret key. Accept only a string containing from 8 to 40 characters.") + } // Enable all loggers by now. enableLoggers()