Skip to content

Commit c9f3c95

Browse files
authored
fix(keystone): distribute permissions when the organization changes (#23504)
1 parent 8deaead commit c9f3c95

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/cloudcommon/db/standalone_anon.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ package db
1616

1717
import (
1818
"context"
19+
"crypto/md5"
20+
"fmt"
1921
"strings"
2022

2123
"yunion.io/x/jsonutils"
@@ -52,6 +54,9 @@ type SStandaloneAnonResourceBase struct {
5254
// 是否是模拟资源, 部分从公有云上同步的资源并不真实存在, 例如宿主机
5355
// list 接口默认不会返回这类资源,除非显示指定 is_emulate=true 过滤参数
5456
IsEmulated bool `nullable:"false" default:"false" list:"admin" create:"admin_optional" json:"is_emulated"`
57+
58+
// 用以组织架构变更通知其他服务权限变更
59+
OrgNodeMd5 string `width:"32" charset:"ascii" nullable:"true"`
5560
}
5661

5762
func (model *SStandaloneAnonResourceBase) BeforeInsert() {
@@ -365,6 +370,11 @@ func (model *SStandaloneAnonResourceBase) SetOrganizationMetadataAll(ctx context
365370
return errors.Wrap(err, "SetAllOrganization")
366371
}
367372
}
373+
Update(model, func() error {
374+
model.OrgNodeMd5 = fmt.Sprintf("%x", md5.Sum([]byte(jsonutils.Marshal(meta).String())))
375+
return nil
376+
})
377+
368378
// 避免加入组织架构后,项目所在的层级会移除此项目
369379
//{
370380
// userTags := make(map[string]interface{})

0 commit comments

Comments
 (0)