mirror of
https://github.com/minio/minio.git
synced 2025-04-25 12:34:03 -04: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")
|
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…
x
Reference in New Issue
Block a user