diff options
| author | 石昌林 <changlin.shi@ly.com> | 2022-07-13 11:36:11 +0800 |
|---|---|---|
| committer | 石昌林 <changlin.shi@ly.com> | 2022-07-13 11:36:11 +0800 |
| commit | ad5e8f68ec04c37d16b3c86834e1ecc524c2680b (patch) | |
| tree | cc828ae2ae92c19d5ea0c554861862a033becdce | |
| parent | fba5219dab83f312de5a0b8ea7ace0e26f6e73a1 (diff) | |
| download | seaweedfs-ad5e8f68ec04c37d16b3c86834e1ecc524c2680b.tar.xz seaweedfs-ad5e8f68ec04c37d16b3c86834e1ecc524c2680b.zip | |
Check whether there is a duplicate accessKey when modifying iam
| -rw-r--r-- | weed/shell/command_s3_configure.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/weed/shell/command_s3_configure.go b/weed/shell/command_s3_configure.go index ddcafd847..c3c0a0d34 100644 --- a/weed/shell/command_s3_configure.go +++ b/weed/shell/command_s3_configure.go @@ -2,6 +2,7 @@ package shell import ( "bytes" + "errors" "flag" "fmt" "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) } + 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() filer.ProtoToText(&buf, s3cfg) |
