Validate access/secret keys found in the config file and enhance invalid keys messages (#3017)

master
Anis Elleuch 8 years ago committed by Harshavardhana
parent 0e2cd1a64d
commit c21ac80268
  1. 12
      cmd/main.go

@ -178,18 +178,18 @@ func Main() {
accessKey := os.Getenv("MINIO_ACCESS_KEY") accessKey := os.Getenv("MINIO_ACCESS_KEY")
secretKey := os.Getenv("MINIO_SECRET_KEY") secretKey := os.Getenv("MINIO_SECRET_KEY")
if accessKey != "" && secretKey != "" { if accessKey != "" && secretKey != "" {
if !isValidAccessKey.MatchString(accessKey) {
fatalIf(errInvalidArgument, "Invalid access key.")
}
if !isValidSecretKey.MatchString(secretKey) {
fatalIf(errInvalidArgument, "Invalid secret key.")
}
// Set new credentials. // Set new credentials.
serverConfig.SetCredential(credential{ serverConfig.SetCredential(credential{
AccessKeyID: accessKey, AccessKeyID: accessKey,
SecretAccessKey: secretKey, 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. // Enable all loggers by now.
enableLoggers() enableLoggers()

Loading…
Cancel
Save