fear: (rbac) init load permission json file.
register list permission router
This commit is contained in:
parent
2e8f39f9b5
commit
a377918e9d
|
@ -0,0 +1,206 @@
|
|||
{
|
||||
"list": [
|
||||
"msearch",
|
||||
"info",
|
||||
"bulk",
|
||||
"count",
|
||||
"delete",
|
||||
"termvectors",
|
||||
"ping",
|
||||
"mtermvectors",
|
||||
"exists",
|
||||
"explain",
|
||||
"index",
|
||||
"search",
|
||||
"scroll",
|
||||
"update",
|
||||
"get",
|
||||
"create",
|
||||
"reindex",
|
||||
"scripts",
|
||||
"mget"
|
||||
],
|
||||
"bulk": [
|
||||
"bulk"
|
||||
],
|
||||
"cat": [
|
||||
"cat.indices",
|
||||
"cat.help",
|
||||
"cat.repositories",
|
||||
"cat.pending_tasks",
|
||||
"cat.tasks",
|
||||
"cat.allocation",
|
||||
"cat.count",
|
||||
"cat.shards",
|
||||
"cat.aliases",
|
||||
"cat.nodeattrs",
|
||||
"cat.templates",
|
||||
"cat.thread_pool",
|
||||
"cat.health",
|
||||
"cat.recovery",
|
||||
"cat.fielddata",
|
||||
"cat.nodes",
|
||||
"cat.plugins",
|
||||
"cat.segments",
|
||||
"cat.snapshots",
|
||||
"cat.master"
|
||||
],
|
||||
"cluster": [
|
||||
"cluster.health",
|
||||
"cluster.get_settings",
|
||||
"cluster.pending_tasks",
|
||||
"cluster.stats",
|
||||
"cluster.remote_info",
|
||||
"cluster.allocation_explain",
|
||||
"cluster.put_settings",
|
||||
"cluster.reroute",
|
||||
"cluster.state"
|
||||
],
|
||||
"count": [
|
||||
"count"
|
||||
],
|
||||
"doc": [
|
||||
"doc.update",
|
||||
"doc.put",
|
||||
"doc.create",
|
||||
"doc.delete"
|
||||
],
|
||||
"exists": [
|
||||
"exists"
|
||||
],
|
||||
"explain": [
|
||||
"explain"
|
||||
],
|
||||
"field_caps": [
|
||||
"field_caps"
|
||||
],
|
||||
"get": [
|
||||
"get"
|
||||
],
|
||||
"indices": [
|
||||
"indices.exists_alias",
|
||||
"indices.get_alias",
|
||||
"indices.recovery",
|
||||
"indices.delete",
|
||||
"indices.clear_cache",
|
||||
"indices.update_by_query",
|
||||
"indices.shrink",
|
||||
"indices.forcemerge",
|
||||
"indices.put_alias",
|
||||
"indices.create",
|
||||
"indices.split",
|
||||
"indices.flush",
|
||||
"indices.get_mapping",
|
||||
"indices.upgrade",
|
||||
"indices.validate_query",
|
||||
"indices.exists_template",
|
||||
"indices.get_upgrade",
|
||||
"indices.update_aliases",
|
||||
"indices.analyze",
|
||||
"indices.exists",
|
||||
"indices.close",
|
||||
"indices.delete_template",
|
||||
"indices.get_field_mapping",
|
||||
"indices.delete_alias",
|
||||
"indices.exists_type",
|
||||
"indices.get_template",
|
||||
"indices.put_template",
|
||||
"indices.refresh",
|
||||
"indices.segments",
|
||||
"indices.termvectors",
|
||||
"indices.flush_synced",
|
||||
"indices.put_mapping",
|
||||
"indices.get",
|
||||
"indices.get_settings",
|
||||
"indices.open",
|
||||
"indices.put_settings",
|
||||
"indices.stats",
|
||||
"indices.delete_by_query",
|
||||
"indices.rollover",
|
||||
"indices.shard_stores"
|
||||
],
|
||||
"info": [
|
||||
"info"
|
||||
],
|
||||
"ingest": [
|
||||
"ingest.delete_pipeline",
|
||||
"ingest.put_pipeline",
|
||||
"ingest.simulate",
|
||||
"ingest.get_pipeline",
|
||||
"ingest.processor_grok"
|
||||
],
|
||||
"mget": [
|
||||
"mget"
|
||||
],
|
||||
"msearch": [
|
||||
"msearch"
|
||||
],
|
||||
"msearch_template": [
|
||||
"msearch_template"
|
||||
],
|
||||
"mtermvectors": [
|
||||
"mtermvectors"
|
||||
],
|
||||
"nodes": [
|
||||
"nodes.info",
|
||||
"nodes.stats",
|
||||
"nodes.reload_secure_settings",
|
||||
"nodes.usage",
|
||||
"nodes.hot_threads"
|
||||
],
|
||||
"ping": [
|
||||
"ping"
|
||||
],
|
||||
"rank_eval": [
|
||||
"rank_eval"
|
||||
],
|
||||
"reindex": [
|
||||
"reindex"
|
||||
],
|
||||
"reindex_rethrottle": [
|
||||
"reindex_rethrottle"
|
||||
],
|
||||
"render_search_template": [
|
||||
"render_search_template"
|
||||
],
|
||||
"scripts": [
|
||||
"scripts.get",
|
||||
"scripts.put",
|
||||
"scripts.delete"
|
||||
],
|
||||
"scripts_painless_execute": [
|
||||
"scripts_painless_execute"
|
||||
],
|
||||
"scroll": [
|
||||
"scroll.delete"
|
||||
],
|
||||
"search": [
|
||||
"search"
|
||||
],
|
||||
"search_shards": [
|
||||
"search_shards"
|
||||
],
|
||||
"search_template": [
|
||||
"search_template"
|
||||
],
|
||||
"snapshot": [
|
||||
"snapshot.get_repository",
|
||||
"snapshot.create_repository",
|
||||
"snapshot.create",
|
||||
"snapshot.restore",
|
||||
"snapshot.status",
|
||||
"snapshot.delete",
|
||||
"snapshot.delete_repository",
|
||||
"snapshot.verify_repository",
|
||||
"snapshot.get"
|
||||
],
|
||||
"source": [
|
||||
"source.head",
|
||||
"source.get"
|
||||
],
|
||||
"tasks": [
|
||||
"tasks.list",
|
||||
"tasks.cancel",
|
||||
"tasks.get"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package biz
|
||||
|
||||
var CategoryApi = make(map[string][]string)
|
||||
|
||||
type ConsolePermisson struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func ListConsolePermisson() (list []ConsolePermisson, err error) {
|
||||
list = []ConsolePermisson{
|
||||
{
|
||||
Id: "1",
|
||||
Name: "数据管理",
|
||||
},
|
||||
{
|
||||
Id: "2",
|
||||
Name: "网关管理",
|
||||
},
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type ElasticsearchPermisson struct {
|
||||
IndexPrivileges []string `json:"index_privileges"`
|
||||
ClusterPrivileges []string `json:"cluster_privileges"`
|
||||
}
|
||||
|
||||
func ListElasticsearchPermisson() (permisson ElasticsearchPermisson, err error) {
|
||||
|
||||
permisson = ElasticsearchPermisson{
|
||||
ClusterPrivileges: CategoryApi["list"],
|
||||
}
|
||||
return
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package rbac
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"infini.sh/console/plugin/api/rbac/biz"
|
||||
"infini.sh/framework/core/api"
|
||||
"infini.sh/framework/core/util"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
type Permisson struct {
|
||||
api.Handler
|
||||
}
|
||||
|
||||
func registerRouter() {
|
||||
p := Permisson{}
|
||||
|
||||
api.HandleAPIMethod(api.GET, "/permission/:type", p.ListPermission)
|
||||
|
||||
}
|
||||
func loadJsonConfig() {
|
||||
pwd, _ := os.Getwd()
|
||||
|
||||
bytes, err := util.FileGetContent(path.Join(pwd, "/config/permission.json"))
|
||||
if err != nil {
|
||||
panic("load json file err " + err.Error())
|
||||
|
||||
}
|
||||
|
||||
err = json.Unmarshal(bytes, &biz.CategoryApi)
|
||||
if err != nil {
|
||||
panic("json config unmarshal err " + err.Error())
|
||||
|
||||
}
|
||||
}
|
||||
func init() {
|
||||
registerRouter()
|
||||
loadJsonConfig()
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package rbac
|
||||
|
||||
import (
|
||||
httprouter "infini.sh/framework/core/api/router"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type RoleType = string
|
||||
|
||||
const (
|
||||
Console RoleType = "console"
|
||||
Elastisearch RoleType = "elasticsearch"
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
Hit interface{} `json:"hit"`
|
||||
}
|
||||
|
||||
func (h Permisson) ListPermission(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue