fix: (rbac) init load EsApis
This commit is contained in:
parent
61d2c8dea7
commit
4afcd7c82f
|
@ -1,29 +1,10 @@
|
||||||
{
|
{
|
||||||
"list": [
|
|
||||||
"msearch",
|
|
||||||
"info",
|
|
||||||
"bulk",
|
|
||||||
"count",
|
|
||||||
"delete",
|
|
||||||
"termvectors",
|
|
||||||
"ping",
|
|
||||||
"mtermvectors",
|
|
||||||
"exists",
|
|
||||||
"explain",
|
|
||||||
"index",
|
|
||||||
"search",
|
|
||||||
"scroll",
|
|
||||||
"update",
|
|
||||||
"get",
|
|
||||||
"create",
|
|
||||||
"reindex",
|
|
||||||
"scripts",
|
|
||||||
"mget"
|
|
||||||
],
|
|
||||||
"bulk": [
|
"bulk": [
|
||||||
"bulk"
|
"bulk"
|
||||||
],
|
],
|
||||||
"cat": [
|
"cat": [
|
||||||
|
"*",
|
||||||
"cat.indices",
|
"cat.indices",
|
||||||
"cat.help",
|
"cat.help",
|
||||||
"cat.repositories",
|
"cat.repositories",
|
||||||
|
@ -46,6 +27,7 @@
|
||||||
"cat.master"
|
"cat.master"
|
||||||
],
|
],
|
||||||
"cluster": [
|
"cluster": [
|
||||||
|
"*",
|
||||||
"cluster.health",
|
"cluster.health",
|
||||||
"cluster.get_settings",
|
"cluster.get_settings",
|
||||||
"cluster.pending_tasks",
|
"cluster.pending_tasks",
|
||||||
|
@ -57,15 +39,18 @@
|
||||||
"cluster.state"
|
"cluster.state"
|
||||||
],
|
],
|
||||||
"count": [
|
"count": [
|
||||||
|
"*",
|
||||||
"count"
|
"count"
|
||||||
],
|
],
|
||||||
"doc": [
|
"doc": [
|
||||||
|
"*",
|
||||||
"doc.update",
|
"doc.update",
|
||||||
"doc.put",
|
"doc.put",
|
||||||
"doc.create",
|
"doc.create",
|
||||||
"doc.delete"
|
"doc.delete"
|
||||||
],
|
],
|
||||||
"exists": [
|
"exists": [
|
||||||
|
"*",
|
||||||
"exists"
|
"exists"
|
||||||
],
|
],
|
||||||
"explain": [
|
"explain": [
|
||||||
|
|
|
@ -1,21 +1,39 @@
|
||||||
package biz
|
package biz
|
||||||
|
|
||||||
var CategoryApi = make(map[string][]string)
|
var ClusterApis = make([]string, 0)
|
||||||
|
var EsApis = make(map[string][]string)
|
||||||
|
|
||||||
type ConsolePermisson struct {
|
type ConsolePermisson struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
func ListConsolePermisson() (list []ConsolePermisson, err error) {
|
func ListConsolePermisson() (list []ConsolePermisson, err error) {
|
||||||
list = []ConsolePermisson{
|
list = []ConsolePermisson{
|
||||||
{
|
{
|
||||||
Id: "1",
|
Id: "cluster_overview",
|
||||||
Name: "数据管理",
|
Name: "平台概览",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Id: "2",
|
Id: "cluster_search",
|
||||||
Name: "网关管理",
|
Name: "平台搜索",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Id: "cluster_elasticsearch",
|
||||||
|
Name: "集群监控",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Id: "cluster_elasticsearch_refresh",
|
||||||
|
Name: "集群监控刷新",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Id: "cluster_activities",
|
||||||
|
Name: "集群动态",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Id: "cluster_activities_search",
|
||||||
|
Name: "集群动态搜索",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -29,8 +47,8 @@ type ElasticsearchPermisson struct {
|
||||||
func ListElasticsearchPermisson() (permisson ElasticsearchPermisson, err error) {
|
func ListElasticsearchPermisson() (permisson ElasticsearchPermisson, err error) {
|
||||||
|
|
||||||
permisson = ElasticsearchPermisson{
|
permisson = ElasticsearchPermisson{
|
||||||
ClusterPrivileges: CategoryApi["list"],
|
ClusterPrivileges: ClusterApis,
|
||||||
IndexPrivileges: CategoryApi["indices"],
|
IndexPrivileges: EsApis["indices"],
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ func registerRouter() {
|
||||||
api.HandleAPIMethod(api.GET, "/roles", r.ListRole)
|
api.HandleAPIMethod(api.GET, "/roles", r.ListRole)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO 权限一级配置全局变量,
|
||||||
func loadJsonConfig() {
|
func loadJsonConfig() {
|
||||||
pwd, _ := os.Getwd()
|
pwd, _ := os.Getwd()
|
||||||
|
|
||||||
|
@ -32,11 +34,17 @@ func loadJsonConfig() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(bytes, &biz.CategoryApi)
|
err = json.Unmarshal(bytes, &biz.EsApis)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("json config unmarshal err " + err.Error())
|
panic("json config unmarshal err " + err.Error())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
list := make([]string, 0)
|
||||||
|
list = append(list, "*")
|
||||||
|
for k := range biz.EsApis {
|
||||||
|
list = append(list, k)
|
||||||
|
}
|
||||||
|
biz.ClusterApis = list
|
||||||
|
|
||||||
}
|
}
|
||||||
func init() {
|
func init() {
|
||||||
registerRouter()
|
registerRouter()
|
||||||
|
|
Loading…
Reference in New Issue