Browse Source

filter duplicated action

pull/3340/head
Tuan Vuong 2 years ago
parent
commit
312e13416b
  1. 13
      weed/iamapi/iamapi_management_handlers.go

13
weed/iamapi/iamapi_management_handlers.go

@ -219,8 +219,16 @@ func (iama *IamApiServer) PutUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values
if userName != ident.Name { if userName != ident.Name {
continue continue
} }
existedActions := make(map[string]bool, len(ident.Actions))
for _, action := range ident.Actions {
existedActions[action] = true
}
for _, action := range actions { for _, action := range actions {
ident.Actions = append(ident.Actions, action)
if !existedActions[action] {
ident.Actions = append(ident.Actions, action)
}
} }
return resp, nil return resp, nil
} }
@ -349,7 +357,8 @@ func (iama *IamApiServer) CreateAccessKey(s3cfg *iam_pb.S3ApiConfiguration, valu
} }
if !changed { if !changed {
s3cfg.Identities = append(s3cfg.Identities, s3cfg.Identities = append(s3cfg.Identities,
&iam_pb.Identity{Name: userName,
&iam_pb.Identity{
Name: userName,
Credentials: []*iam_pb.Credential{ Credentials: []*iam_pb.Credential{
{ {
AccessKey: accessKeyId, AccessKey: accessKeyId,

Loading…
Cancel
Save