mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
clarify error message for root user credential (#20043)
Signed-off-by: Austin Chang <austin880625@gmail.com>
This commit is contained in:
parent
ce183cb2b4
commit
5f64658faa
@ -843,6 +843,7 @@ func loadRootCredentials() {
|
||||
// Check both cases and authenticate them if correctly defined
|
||||
var user, password string
|
||||
var hasCredentials bool
|
||||
var legacyCredentials bool
|
||||
//nolint:gocritic
|
||||
if env.IsSet(config.EnvRootUser) && env.IsSet(config.EnvRootPassword) {
|
||||
user = env.Get(config.EnvRootUser, "")
|
||||
@ -851,6 +852,7 @@ func loadRootCredentials() {
|
||||
} else if env.IsSet(config.EnvAccessKey) && env.IsSet(config.EnvSecretKey) {
|
||||
user = env.Get(config.EnvAccessKey, "")
|
||||
password = env.Get(config.EnvSecretKey, "")
|
||||
legacyCredentials = true
|
||||
hasCredentials = true
|
||||
} else if globalServerCtxt.RootUser != "" && globalServerCtxt.RootPwd != "" {
|
||||
user, password = globalServerCtxt.RootUser, globalServerCtxt.RootPwd
|
||||
@ -859,8 +861,13 @@ func loadRootCredentials() {
|
||||
if hasCredentials {
|
||||
cred, err := auth.CreateCredentials(user, password)
|
||||
if err != nil {
|
||||
logger.Fatal(config.ErrInvalidCredentials(err),
|
||||
"Unable to validate credentials inherited from the shell environment")
|
||||
if legacyCredentials {
|
||||
logger.Fatal(config.ErrInvalidCredentials(err),
|
||||
"Unable to validate credentials inherited from the shell environment")
|
||||
} else {
|
||||
logger.Fatal(config.ErrInvalidRootUserCredentials(err),
|
||||
"Unable to validate credentials inherited from the shell environment")
|
||||
}
|
||||
}
|
||||
if env.IsSet(config.EnvAccessKey) && env.IsSet(config.EnvSecretKey) {
|
||||
msg := fmt.Sprintf("WARNING: %s and %s are deprecated.\n"+
|
||||
|
@ -73,6 +73,12 @@ var (
|
||||
`Access key length should be at least 3, and secret key length at least 8 characters`,
|
||||
)
|
||||
|
||||
ErrInvalidRootUserCredentials = newErrFn(
|
||||
"Invalid credentials",
|
||||
"Please provide correct credentials",
|
||||
EnvRootUser+` length should be at least 3, and `+EnvRootPassword+` length at least 8 characters`,
|
||||
)
|
||||
|
||||
ErrMissingEnvCredentialRootUser = newErrFn(
|
||||
"Missing credential environment variable, \""+EnvRootUser+"\"",
|
||||
"Environment variable \""+EnvRootUser+"\" is missing",
|
||||
|
Loading…
Reference in New Issue
Block a user