mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-20 13:27:57 +08:00
Merge pull request #3305 from shichanglin5/fix_iam_shell_override
Check whether there is a duplicate accessKey when modifying iam
This commit is contained in:
@@ -2,6 +2,7 @@ package shell
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chrislusf/seaweedfs/weed/filer"
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
@@ -164,6 +165,17 @@ func (c *commandS3Configure) Do(args []string, commandEnv *CommandEnv, writer io
|
|||||||
s3cfg.Identities = append(s3cfg.Identities, &identity)
|
s3cfg.Identities = append(s3cfg.Identities, &identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accessKeySet := make(map[string]string)
|
||||||
|
for _, ident := range s3cfg.Identities {
|
||||||
|
for _, cred := range ident.Credentials {
|
||||||
|
if userName, found := accessKeySet[cred.AccessKey]; !found {
|
||||||
|
accessKeySet[cred.AccessKey] = ident.Name
|
||||||
|
} else {
|
||||||
|
return errors.New(fmt.Sprintf("duplicate accessKey[%s], already configured in user[%s]", cred.AccessKey, userName))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
filer.ProtoToText(&buf, s3cfg)
|
filer.ProtoToText(&buf, s3cfg)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user