mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Validate access/secret keys found in the config file and enhance invalid keys messages (#3017)
This commit is contained in:
parent
0e2cd1a64d
commit
c21ac80268
12
cmd/main.go
12
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()
|
||||
|
Loading…
Reference in New Issue
Block a user