mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(keystone): distribute permissions when the organization changes (#23502)
This commit is contained in:
@@ -16,6 +16,7 @@ package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
@@ -56,6 +57,9 @@ type SStandaloneAnonResourceBase struct {
|
||||
// 是否是模拟资源, 部分从公有云上同步的资源并不真实存在, 例如宿主机
|
||||
// list 接口默认不会返回这类资源,除非显示指定 is_emulate=true 过滤参数
|
||||
IsEmulated bool `nullable:"false" default:"false" list:"admin" create:"admin_optional" json:"is_emulated"`
|
||||
|
||||
// 用以组织架构变更通知其他服务权限变更
|
||||
OrgNodeMd5 string `width:"32" charset:"ascii" nullable:"true"`
|
||||
}
|
||||
|
||||
func (model *SStandaloneAnonResourceBase) BeforeInsert() {
|
||||
@@ -369,6 +373,11 @@ func (model *SStandaloneAnonResourceBase) SetOrganizationMetadataAll(ctx context
|
||||
return errors.Wrap(err, "SetAllOrganization")
|
||||
}
|
||||
}
|
||||
Update(model, func() error {
|
||||
model.OrgNodeMd5 = fmt.Sprintf("%x", md5.Sum([]byte(jsonutils.Marshal(meta).String())))
|
||||
return nil
|
||||
})
|
||||
|
||||
// 避免加入组织架构后,项目所在的层级会移除此项目
|
||||
//{
|
||||
// userTags := make(map[string]interface{})
|
||||
|
||||
Reference in New Issue
Block a user