Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

filter duplicated action

Tuan Vuong312e13416b26
diff --git a/weed/iamapi/iamapi_management_handlers.go b/weed/iamapi/iamapi_management_handlers.go
index e1f215bd33..8a42aa9363 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,