Browse Source

Merge pull request #3305 from shichanglin5/fix_iam_shell_override

Check whether there is a duplicate accessKey when modifying iam
pull/3308/head
Chris Lu 3 years ago
committed by GitHub
parent
commit
31f9f528db
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      weed/shell/command_s3_configure.go

12
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)

Loading…
Cancel
Save