aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2022-07-20 09:01:14 -0700
committerGitHub <noreply@github.com>2022-07-20 09:01:14 -0700
commitefec31de8df321b01c0e20085d0a10e430af2ed6 (patch)
tree9293456f05ccd1c15feaa926a6d5026e6eb96477
parent4820b594a7668db1e31993d473a049c2a48209fb (diff)
parent312e13416b26fd6f1839c09ce82a6e6fe9fec8b9 (diff)
downloadseaweedfs-efec31de8df321b01c0e20085d0a10e430af2ed6.tar.xz
seaweedfs-efec31de8df321b01c0e20085d0a10e430af2ed6.zip
Merge pull request #3340 from vanhtuan0409/put-user-policy
-rw-r--r--weed/iamapi/iamapi_management_handlers.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/weed/iamapi/iamapi_management_handlers.go b/weed/iamapi/iamapi_management_handlers.go
index e1f215bd3..8a42aa936 100644
--- a/weed/iamapi/iamapi_management_handlers.go
+++ b/weed/iamapi/iamapi_management_handlers.go
@@ -219,8 +219,16 @@ func (iama *IamApiServer) PutUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values
if userName != ident.Name {
continue
}
+
+ existedActions := make(map[string]bool, len(ident.Actions))
+ for _, action := range ident.Actions {
+ existedActions[action] = true
+ }
+
for _, action := range actions {
- ident.Actions = append(ident.Actions, action)
+ if !existedActions[action] {
+ ident.Actions = append(ident.Actions, action)
+ }
}
return resp, nil
}
@@ -349,7 +357,8 @@ func (iama *IamApiServer) CreateAccessKey(s3cfg *iam_pb.S3ApiConfiguration, valu
}
if !changed {
s3cfg.Identities = append(s3cfg.Identities,
- &iam_pb.Identity{Name: userName,
+ &iam_pb.Identity{
+ Name: userName,
Credentials: []*iam_pb.Credential{
{
AccessKey: accessKeyId,