fix: (rbac) create es role
This commit is contained in:
parent
231e174aff
commit
006e162523
|
@ -39,10 +39,10 @@ type MenuPermission struct {
|
||||||
Privilege string `json:"privilege"`
|
Privilege string `json:"privilege"`
|
||||||
}
|
}
|
||||||
type ElasticsearchRole struct {
|
type ElasticsearchRole struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description" `
|
Description string `json:"description" `
|
||||||
RoleType string `json:"type" `
|
RoleType string `json:"type" `
|
||||||
Permission interface{} `json:"permission"`
|
rbac.ElasticRole
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRole(typ string) (r IRole, err error) {
|
func NewRole(typ string) (r IRole, err error) {
|
||||||
|
@ -132,8 +132,10 @@ func (role ElasticsearchRole) Create(localUser *User) (id string, err error) {
|
||||||
Name: role.Name,
|
Name: role.Name,
|
||||||
Description: role.Description,
|
Description: role.Description,
|
||||||
RoleType: role.RoleType,
|
RoleType: role.RoleType,
|
||||||
Permission: role.Permission,
|
|
||||||
}
|
}
|
||||||
|
newRole.Cluster = role.Cluster
|
||||||
|
newRole.Index = role.Index
|
||||||
|
newRole.ClusterPrivilege = role.ClusterPrivilege
|
||||||
newRole.ID = util.GetUUID()
|
newRole.ID = util.GetUUID()
|
||||||
newRole.Created = time.Now()
|
newRole.Created = time.Now()
|
||||||
newRole.Updated = time.Now()
|
newRole.Updated = time.Now()
|
||||||
|
@ -151,10 +153,10 @@ func (role ElasticsearchRole) Create(localUser *User) (id string, err error) {
|
||||||
"id": id,
|
"id": id,
|
||||||
"name": role.Name,
|
"name": role.Name,
|
||||||
"description": role.Description,
|
"description": role.Description,
|
||||||
"permission": role.Permission,
|
|
||||||
"type": role.RoleType,
|
"type": role.RoleType,
|
||||||
"created": newRole.Created.Format("2006-01-02 15:04:05"),
|
"created": newRole.Created.Format("2006-01-02 15:04:05"),
|
||||||
"updated": newRole.Updated.Format("2006-01-02 15:04:05"),
|
"updated": newRole.Updated.Format("2006-01-02 15:04:05"),
|
||||||
},
|
},
|
||||||
User: util.MapStr{
|
User: util.MapStr{
|
||||||
"userid": localUser.UserId,
|
"userid": localUser.UserId,
|
||||||
|
|
|
@ -9,8 +9,9 @@ type Role struct {
|
||||||
Name string `json:"name" elastic_mapping:"name:{type:keyword}"`
|
Name string `json:"name" elastic_mapping:"name:{type:keyword}"`
|
||||||
Description string `json:"description" elastic_mapping:"description:{type:text}"`
|
Description string `json:"description" elastic_mapping:"description:{type:text}"`
|
||||||
RoleType string `json:"type" elastic_mapping:"type:{type:keyword}"`
|
RoleType string `json:"type" elastic_mapping:"type:{type:keyword}"`
|
||||||
Permission interface{} `json:"permission" elastic_mapping:"permission:{type:object}"`
|
Permission interface{} `json:"permission,omitempty" elastic_mapping:"permission:{type:object}"`
|
||||||
BuiltIn bool `json:"builtin" elastic_mapping:"builtin:{type:boolean}"` //是否内置
|
BuiltIn bool `json:"builtin" elastic_mapping:"builtin:{type:boolean}"` //是否内置
|
||||||
|
ElasticRole
|
||||||
}
|
}
|
||||||
type ConsolePermission struct {
|
type ConsolePermission struct {
|
||||||
Api []string `json:"api"`
|
Api []string `json:"api"`
|
||||||
|
@ -22,9 +23,15 @@ type Menu struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Privilege string `json:"privilege"`
|
Privilege string `json:"privilege"`
|
||||||
}
|
}
|
||||||
type ElasticsearchPermission struct {
|
|
||||||
Cluster []string `json:"cluster" elastic_mapping:"cluster:{type:object}"`
|
type ElasticRole struct {
|
||||||
Index []string `json:"index" elastic_mapping:"index:{type:object}"`
|
Cluster []struct {
|
||||||
ClusterPrivilege []string `json:"cluster_privilege" elastic_mapping:"cluster_privilege:{type:object}"`
|
Id string `json:"id"`
|
||||||
IndexPrivilege []string `json:"index_privilege" elastic_mapping:"index_privilege:{type:object}"`
|
Name string `json:"name"`
|
||||||
|
} `json:"cluster,omitempty"`
|
||||||
|
ClusterPrivilege []map[string][]string `json:"cluster_privilege,omitempty"`
|
||||||
|
Index []struct {
|
||||||
|
Name []string `json:"name"`
|
||||||
|
Privilege []string `json:"privilege"`
|
||||||
|
} `json:"index,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue