fix: (rbac) update user roles

This commit is contained in:
xushuhui 2022-04-25 15:27:18 +08:00
parent 98db1cdff7
commit c000596e66
15 changed files with 706 additions and 415 deletions

View File

@ -1,271 +1,270 @@
{
"DELETE/_ingest/pipeline/:id": "ingest.delete_pipeline",
"DELETE/_scripts/:id": "delete_script",
"DELETE/_search/scroll": "clear_scroll",
"DELETE/_search/scroll/:scroll_id": "clear_scroll",
"DELETE/_snapshot/:repository": "snapshot.delete_repository",
"DELETE/_snapshot/:repository/:snapshot": "snapshot.delete",
"DELETE/_template/:name": "indices.delete_template",
"DELETE/:index": "indices.delete",
"DELETE/:index/_alias/:name": "indices.delete_alias",
"DELETE/:index/_aliases/:name": "indices.delete_alias",
"DELETE/:index/_doc/:id": "delete",
"DELETE-/_ingest/pipeline/:id": "ingest.delete_pipeline",
"DELETE-/_scripts/:id": "DELETE-_script",
"DELETE-/_search/scroll": "clear_scroll",
"DELETE-/_search/scroll/:scroll_id": "clear_scroll",
"DELETE-/_snapshot/:repository": "snapshot.delete_repository",
"DELETE-/_snapshot/:repository/:snapshot": "snapshot.delete",
"DELETE-/_template/:name": "indices.delete_template",
"DELETE-/:index": "indices.delete",
"DELETE-/:index/_alias/:name": "indices.delete_alias",
"DELETE-/:index/_aliases/:name": "indices.delete_alias",
"DELETE-/:index/_doc/:id": "doc.delete",
"GET/": "info",
"GET/_alias": "indices.get_alias",
"GET/_alias/:name": "indices.get_alias",
"GET/_analyze": "indices.analyze",
"GET/_cat": "cat.help",
"GET/_cat/aliases": "cat.aliases",
"GET/_cat/aliases/:name": "cat.aliases",
"GET/_cat/allocation": "cat.allocation",
"GET/_cat/allocation/:node_id": "cat.allocation",
"GET/_cat/count": "cat.count",
"GET/_cat/count/:index": "cat.count",
"GET/_cat/fielddata": "cat.fielddata",
"GET/_cat/fielddata/:fields": "cat.fielddata",
"GET/_cat/health": "cat.health",
"GET/_cat/indices": "cat.indices",
"GET/_cat/indices/:index": "cat.indices",
"GET/_cat/master": "cat.master",
"GET/_cat/nodeattrs": "cat.nodeattrs",
"GET/_cat/nodes": "cat.nodes",
"GET/_cat/pending_tasks": "cat.pending_tasks",
"GET/_cat/plugins": "cat.plugins",
"GET/_cat/recovery": "cat.recovery",
"GET/_cat/recovery/:index": "cat.recovery",
"GET/_cat/repositories": "cat.repositories",
"GET/_cat/segments": "cat.segments",
"GET/_cat/segments/:index": "cat.segments",
"GET/_cat/shards": "cat.shards",
"GET/_cat/shards/:index": "cat.shards",
"GET/_cat/snapshots": "cat.snapshots",
"GET/_cat/snapshots/:repository": "cat.snapshots",
"GET/_cat/tasks": "cat.tasks",
"GET/_cat/templates": "cat.templates",
"GET/_cat/templates/:name": "cat.templates",
"GET/_cat/thread_pool": "cat.thread_pool",
"GET/_cat/thread_pool/:thread_pool_patterns": "cat.thread_pool",
"GET/_cluster/allocation/explain": "cluster.allocation_explain",
"GET/_cluster/health": "cluster.health",
"GET/_cluster/health/:index": "cluster.health",
"GET/_cluster/nodes/hot_threads": "nodes.hot_threads",
"GET/_cluster/nodes/hotthreads": "nodes.hot_threads",
"GET/_cluster/nodes/:node_id/hot_threads": "nodes.hot_threads",
"GET/_cluster/nodes/:node_id/hotthreads": "nodes.hot_threads",
"GET/_cluster/pending_tasks": "cluster.pending_tasks",
"GET/_cluster/settings": "cluster.get_settings",
"GET/_cluster/state": "cluster.state",
"GET/_cluster/state/:metric": "cluster.state",
"GET/_cluster/state/:metric/:index": "cluster.state",
"GET/_cluster/stats": "cluster.stats",
"GET/_cluster/stats/nodes/:node_id": "cluster.stats",
"GET/_count": "count",
"GET/_field_caps": "field_caps",
"GET/_flush": "indices.flush",
"GET/_flush/synced": "indices.flush_synced",
"GET/_ingest/pipeline": "ingest.get_pipeline",
"GET/_ingest/pipeline/_simulate": "ingest.simulate",
"GET/_ingest/pipeline/:id": "ingest.get_pipeline",
"GET/_ingest/pipeline/:id/_simulate": "ingest.simulate",
"GET/_ingest/processor/grok": "ingest.processor_grok",
"GET/_mapping": "indices.get_mapping",
"GET-/": "info",
"GET-/_alias": "indices.get_alias",
"GET-/_alias/:name": "indices.get_alias",
"GET-/_analyze": "indices.analyze",
"GET-/_cat": "cat.help",
"GET-/_cat/aliases": "cat.aliases",
"GET-/_cat/aliases/:name": "cat.aliases",
"GET-/_cat/allocation": "cat.allocation",
"GET-/_cat/allocation/:node_id": "cat.allocation",
"GET-/_cat/count": "cat.count",
"GET-/_cat/count/:index": "cat.count",
"GET-/_cat/fielddata": "cat.fielddata",
"GET-/_cat/fielddata/:fields": "cat.fielddata",
"GET-/_cat/health": "cat.health",
"GET-/_cat/indices": "cat.indices",
"GET-/_cat/indices/:index": "cat.indices",
"GET-/_cat/master": "cat.master",
"GET-/_cat/nodeattrs": "cat.nodeattrs",
"GET-/_cat/nodes": "cat.nodes",
"GET-/_cat/pending_tasks": "cat.pending_tasks",
"GET-/_cat/plugins": "cat.plugins",
"GET-/_cat/recovery": "cat.recovery",
"GET-/_cat/recovery/:index": "cat.recovery",
"GET-/_cat/repositories": "cat.repositories",
"GET-/_cat/segments": "cat.segments",
"GET-/_cat/segments/:index": "cat.segments",
"GET-/_cat/shards": "cat.shards",
"GET-/_cat/shards/:index": "cat.shards",
"GET-/_cat/snapshots": "cat.snapshots",
"GET-/_cat/snapshots/:repository": "cat.snapshots",
"GET-/_cat/tasks": "cat.tasks",
"GET-/_cat/templates": "cat.templates",
"GET-/_cat/templates/:name": "cat.templates",
"GET-/_cat/thread_pool": "cat.thread_pool",
"GET-/_cat/thread_pool/:thread_pool_patterns": "cat.thread_pool",
"GET-/_cluster/allocation/explain": "cluster.allocation_explain",
"GET-/_cluster/health": "cluster.health",
"GET-/_cluster/health/:index": "cluster.health",
"GET-/_cluster/nodes/hot_threads": "nodes.hot_threads",
"GET-/_cluster/nodes/hotthreads": "nodes.hot_threads",
"GET-/_cluster/nodes/:node_id/hot_threads": "nodes.hot_threads",
"GET-/_cluster/nodes/:node_id/hotthreads": "nodes.hot_threads",
"GET-/_cluster/pending_tasks": "cluster.pending_tasks",
"GET-/_cluster/settings": "cluster.get_settings",
"GET-/_cluster/state": "cluster.state",
"GET-/_cluster/state/:metric": "cluster.state",
"GET-/_cluster/state/:metric/:index": "cluster.state",
"GET-/_cluster/stats": "cluster.stats",
"GET-/_cluster/stats/nodes/:node_id": "cluster.stats",
"GET-/_count": "count",
"GET-/_field_caps": "field_caps",
"GET-/_flush": "indices.flush",
"GET-/_flush/synced": "indices.flush_synced",
"GET-/_ingest/pipeline": "ingest.get_pipeline",
"GET-/_ingest/pipeline/_simulate": "ingest.simulate",
"GET-/_ingest/pipeline/:id": "ingest.get_pipeline",
"GET-/_ingest/pipeline/:id/_simulate": "ingest.simulate",
"GET-/_ingest/processor/grok": "ingest.processor_grok",
"GET-/_mapping": "indices.get_mapping",
"GET/_mapping/:index": "indices.get_mapping",
"GET/_mapping/:index/field/:fields": "indices.get_field_mapping",
"GET/_mget": "mget",
"GET/_msearch": "msearch",
"GET/_msearch/template": "msearch_template",
"GET/_mtermvectors": "mtermvectors",
"GET/_nodes": "nodes.info",
"GET/_nodes/hot_threads": "nodes.hot_threads",
"GET/_nodes/hotthreads": "nodes.hot_threads",
"GET/_nodes/stats": "nodes.stats",
"GET/_nodes/stats/:metric": "nodes.stats",
"GET/_nodes/stats/:metric/:index_metric": "nodes.stats",
"GET/_nodes/usage": "nodes.usage",
"GET/_nodes/usage/:metric": "nodes.usage",
"GET/_nodes/:metric": "nodes.info",
"GET/_nodes/:node_id": "nodes.info",
"GET/_nodes/:node_id/hot_threads": "nodes.hot_threads",
"GET/_nodes/:node_id/hotthreads": "nodes.hot_threads",
"GET/_nodes/:node_id/stats": "nodes.stats",
"GET/_nodes/:node_id/stats/:metric": "nodes.stats",
"GET/_nodes/:node_id/stats/:metric/:index_metric": "nodes.stats",
"GET/_nodes/:node_id/usage": "nodes.usage",
"GET/_nodes/:node_id/usage/:metric": "nodes.usage",
"GET/_nodes/:node_id/:metric": "nodes.info",
"GET/_rank_eval": "rank_eval",
"GET/_recovery": "indices.recovery",
"GET/_refresh": "indices.refresh",
"GET/_remote/info": "cluster.remote_info",
"GET/_render/template": "render_search_template",
"GET/_render/template/:id": "render_search_template",
"GET/_scripts/painless/_execute": "scripts_painless_execute",
"GET/_scripts/:id": "get_script",
"GET/_search": "search",
"GET/_search/scroll": "scroll",
"GET/_search/scroll/:scroll_id": "scroll",
"GET/_search/template": "search_template",
"GET/_search_shards": "search_shards",
"GET/_segments": "indices.segments",
"GET/_settings": "indices.get_settings",
"GET/_settings/:name": "indices.get_settings",
"GET/_shard_stores": "indices.shard_stores",
"GET/_snapshot": "snapshot.get_repository",
"GET/_snapshot/_status": "snapshot.status",
"GET/_snapshot/:repository": "snapshot.get_repository",
"GET/_snapshot/:repository/_status": "snapshot.status",
"GET/_snapshot/:repository/:snapshot": "snapshot.get",
"GET/_snapshot/:repository/:snapshot/_status": "snapshot.status",
"GET/_stats": "indices.stats",
"GET/_stats/:metric": "indices.stats",
"GET/_tasks": "tasks.list",
"GET/_tasks/:task_id": "tasks.get",
"GET/_template": "indices.get_template",
"GET/_template/:name": "indices.get_template",
"GET/_upgrade": "indices.get_upgrade",
"GET/_validate/query": "indices.validate_query",
"GET/:index": "indices.get",
"GET/:index/_alias": "indices.get_alias",
"GET/:index/_alias/:name": "indices.get_alias",
"GET/:index/_analyze": "indices.analyze",
"GET/:index/_count": "count",
"GET/:index/_doc/:id": "get",
"GET/:index/_field_caps": "field_caps",
"GET/:index/_flush": "indices.flush",
"GET/:index/_flush/synced": "indices.flush_synced",
"GET/:index/_mapping": "indices.get_mapping",
"GET/:index/_mapping/field/:fields": "indices.get_field_mapping",
"GET-/_mget": "mget",
"GET-/_msearch": "msearch",
"GET-/_msearch/template": "msearch_template",
"GET-/_mtermvectors": "mtermvectors",
"GET-/_nodes": "nodes.info",
"GET-/_nodes/hot_threads": "nodes.hot_threads",
"GET-/_nodes/hotthreads": "nodes.hot_threads",
"GET-/_nodes/stats": "nodes.stats",
"GET-/_nodes/stats/:metric": "nodes.stats",
"GET-/_nodes/stats/:metric/:index_metric": "nodes.stats",
"GET-/_nodes/usage": "nodes.usage",
"GET-/_nodes/usage/:metric": "nodes.usage",
"GET-/_nodes/:metric": "nodes.info",
"GET-/_nodes/:node_id": "nodes.info",
"GET-/_nodes/:node_id/hot_threads": "nodes.hot_threads",
"GET-/_nodes/:node_id/hotthreads": "nodes.hot_threads",
"GET-/_nodes/:node_id/stats": "nodes.stats",
"GET-/_nodes/:node_id/stats/:metric": "nodes.stats",
"GET-/_nodes/:node_id/stats/:metric/:index_metric": "nodes.stats",
"GET-/_nodes/:node_id/usage": "nodes.usage",
"GET-/_nodes/:node_id/usage/:metric": "nodes.usage",
"GET-/_nodes/:node_id/:metric": "nodes.info",
"GET-/_rank_eval": "rank_eval",
"GET-/_recovery": "indices.recovery",
"GET-/_refresh": "indices.refresh",
"GET-/_remote/info": "cluster.remote_info",
"GET-/_render/template": "render_search_template",
"GET-/_render/template/:id": "render_search_template",
"GET-/_scripts/painless/_execute": "scripts_painless_execute",
"GET-/_scripts/:id": "get_script",
"GET-/_search": "search",
"GET-/_search/scroll": "scroll",
"GET-/_search/scroll/:scroll_id": "scroll",
"GET-/_search/template": "search_template",
"GET-/_search_shards": "search_shards",
"GET-/_segments": "indices.segments",
"GET-/_settings": "indices.get_settings",
"GET-/_settings/:name": "indices.get_settings",
"GET-/_shard_stores": "indices.shard_stores",
"GET-/_snapshot": "snapshot.get_repository",
"GET-/_snapshot/_status": "snapshot.status",
"GET-/_snapshot/:repository": "snapshot.get_repository",
"GET-/_snapshot/:repository/_status": "snapshot.status",
"GET-/_snapshot/:repository/:snapshot": "snapshot.get",
"GET-/_snapshot/:repository/:snapshot/_status": "snapshot.status",
"GET-/_stats": "indices.stats",
"GET-/_stats/:metric": "indices.stats",
"GET-/_tasks": "tasks.list",
"GET-/_tasks/:task_id": "tasks.get",
"GET-/_template": "indices.get_template",
"GET-/_template/:name": "indices.get_template",
"GET-/_upgrade": "indices.get_upgrade",
"GET-/_validate/query": "indices.validate_query",
"GET-/:index": "indices.get",
"GET-/:index/_alias": "indices.get_alias",
"GET-/:index/_alias/:name": "indices.get_alias",
"GET-/:index/_analyze": "indices.analyze",
"GET-/:index/_count": "count",
"GET-/:index/_doc/:id": "doc.get",
"GET-/:index/_field_caps": "field_caps",
"GET-/:index/_flush": "indices.flush",
"GET-/:index/_flush/synced": "indices.flush_synced",
"GET-/:index/_mapping": "indices.get_mapping",
"GET-/:index/_mappings": "indices.get_mapping",
"GET-/:index/_mapping/field/:fields": "indices.get_field_mapping",
"GET/:index/_mget": "mget",
"GET/:index/_msearch": "msearch",
"GET/:index/_msearch/template": "msearch_template",
"GET/:index/_mtermvectors": "mtermvectors",
"GET/:index/_rank_eval": "rank_eval",
"GET/:index/_recovery": "indices.recovery",
"GET/:index/_refresh": "indices.refresh",
"GET/:index/_search": "search",
"GET/:index/_search/template": "search_template",
"GET/:index/_search_shards": "search_shards",
"GET/:index/_segments": "indices.segments",
"GET/:index/_settings": "indices.get_settings",
"GET/:index/_settings/:name": "indices.get_settings",
"GET/:index/_shard_stores": "indices.shard_stores",
"GET/:index/_stats": "indices.stats",
"GET/:index/_stats/:metric": "indices.stats",
"GET/:index/_upgrade": "indices.get_upgrade",
"GET/:index/_validate/query": "indices.validate_query",
"GET-/:index/_mget": "mget",
"GET-/:index/_msearch": "msearch",
"GET-/:index/_msearch/template": "msearch_template",
"GET-/:index/_mtermvectors": "mtermvectors",
"GET-/:index/_rank_eval": "rank_eval",
"GET-/:index/_recovery": "indices.recovery",
"GET-/:index/_refresh": "indices.refresh",
"GET-/:index/_search": "search",
"GET-/:index/_search/template": "search_template",
"GET-/:index/_search_shards": "search_shards",
"GET-/:index/_segments": "indices.segments",
"GET-/:index/_settings": "indices.get_settings",
"GET-/:index/_settings/:name": "indices.get_settings",
"GET-/:index/_shard_stores": "indices.shard_stores",
"GET-/:index/_stats": "indices.stats",
"GET-/:index/_stats/:metric": "indices.stats",
"GET-/:index/_upgrade": "indices.get_upgrade",
"GET-/:index/_validate/query": "indices.validate_query",
"HEAD/": "info",
"HEAD/_alias/:name": "indices.exists_alias",
"HEAD/_template/:name": "indices.exists_template",
"HEAD/:index": "indices.exists",
"HEAD/:index/_alias/:name": "indices.exists_alias",
"HEAD-/": "info",
"HEAD-/_alias/:name": "indices.exists_alias",
"HEAD-/_template/:name": "indices.exists_template",
"HEAD-/:index": "indices.exists",
"HEAD-/:index/_alias/:name": "indices.exists_alias",
"POST/_aliases": "indices.update_aliases",
"POST/_analyze": "indices.analyze",
"POST/_bulk": "bulk",
"POST/_cache/clear": "indices.clear_cache",
"POST/_cluster/allocation/explain": "cluster.allocation_explain",
"POST/_cluster/reroute": "cluster.reroute",
"POST/_count": "count",
"POST/_delete_by_query/:task_id/_rethrottle": "reindex_rethrottle",
"POST/_field_caps": "field_caps",
"POST/_flush": "indices.flush",
"POST/_flush/synced": "indices.flush_synced",
"POST/_forcemerge": "indices.forcemerge",
"POST/_ingest/pipeline/_simulate": "ingest.simulate",
"POST/_ingest/pipeline/:id/_simulate": "ingest.simulate",
"POST-/_aliases": "indices.update_aliases",
"POST-/_analyze": "indices.analyze",
"POST-/_bulk": "bulk",
"POST-/_cache/clear": "indices.clear_cache",
"POST-/_cluster/allocation/explain": "cluster.allocation_explain",
"POST-/_cluster/reroute": "cluster.reroute",
"POST-/_count": "count",
"POST-/_DELETE-_by_query/:task_id/_rethrottle": "reindex_rethrottle",
"POST-/_field_caps": "field_caps",
"POST-/_flush": "indices.flush",
"POST-/_flush/synced": "indices.flush_synced",
"POST-/_forcemerge": "indices.forcemerge",
"POST-/_ingest/pipeline/_simulate": "ingest.simulate",
"POST-/_ingest/pipeline/:id/_simulate": "ingest.simulate",
"POST/_mget": "mget",
"POST/_msearch": "msearch",
"POST/_msearch/template": "msearch_template",
"POST/_mtermvectors": "mtermvectors",
"POST/_nodes/reload_secure_settings": "nodes.reload_secure_settings",
"POST/_nodes/:node_id/reload_secure_settings": "nodes.reload_secure_settings",
"POST/_rank_eval": "rank_eval",
"POST/_refresh": "indices.refresh",
"POST/_reindex": "reindex",
"POST/_reindex/:task_id/_rethrottle": "reindex_rethrottle",
"POST/_render/template": "render_search_template",
"POST/_render/template/:id": "render_search_template",
"POST/_scripts/painless/_execute": "scripts_painless_execute",
"POST/_scripts/:id": "put_script",
"POST/_scripts/:id/:context": "put_script",
"POST/_search": "search",
"POST/_search/scroll": "scroll",
"POST/_search/scroll/:scroll_id": "scroll",
"POST/_search/template": "search_template",
"POST/_search_shards": "search_shards",
"POST/_snapshot/:repository": "snapshot.create_repository",
"POST/_snapshot/:repository/_verify": "snapshot.verify_repository",
"POST/_snapshot/:repository/:snapshot": "snapshot.create",
"POST/_snapshot/:repository/:snapshot/_restore": "snapshot.restore",
"POST/_tasks/_cancel": "tasks.cancel",
"POST/_tasks/:task_id/_cancel": "tasks.cancel",
"POST/_template/:name": "indices.put_template",
"POST/_update_by_query/:task_id/_rethrottle": "reindex_rethrottle",
"POST/_upgrade": "indices.upgrade",
"POST/_validate/query": "indices.validate_query",
"POST/:alias/_rollover": "indices.rollover",
"POST/:alias/_rollover/:new_index": "indices.rollover",
"POST/:index/_alias/:name": "indices.put_alias",
"POST/:index/_aliases/:name": "indices.put_alias",
"POST/:index/_analyze": "indices.analyze",
"POST/:index/_bulk": "bulk",
"POST/:index/_cache/clear": "indices.clear_cache",
"POST/:index/_close": "indices.close",
"POST/:index/_count": "count",
"POST/:index/_delete_by_query": "delete_by_query",
"POST/:index/_doc": "index",
"POST/:index/_doc/:id": "index",
"POST/:index/_doc/:id/_update": "update",
"POST/:index/_field_caps": "field_caps",
"POST/:index/_flush": "indices.flush",
"POST/:index/_flush/synced": "indices.flush_synced",
"POST/:index/_forcemerge": "indices.forcemerge",
"POST-/_mget": "mget",
"POST-/_msearch": "msearch",
"POST-/_msearch/template": "msearch_template",
"POST-/_mtermvectors": "mtermvectors",
"POST-/_nodes/reload_secure_settings": "nodes.reload_secure_settings",
"POST-/_nodes/:node_id/reload_secure_settings": "nodes.reload_secure_settings",
"POST-/_rank_eval": "rank_eval",
"POST-/_refresh": "indices.refresh",
"POST-/_reindex": "reindex",
"POST-/_reindex/:task_id/_rethrottle": "reindex_rethrottle",
"POST-/_render/template": "render_search_template",
"POST-/_render/template/:id": "render_search_template",
"POST-/_scripts/painless/_execute": "scripts_painless_execute",
"POST-/_scripts/:id": "put_script",
"POST-/_scripts/:id/:context": "put_script",
"POST-/_search": "search",
"POST-/_search/scroll": "scroll",
"POST-/_search/scroll/:scroll_id": "scroll",
"POST-/_search/template": "search_template",
"POST-/_search_shards": "search_shards",
"POST-/_snapshot/:repository": "snapshot.create_repository",
"POST-/_snapshot/:repository/_verify": "snapshot.verify_repository",
"POST-/_snapshot/:repository/:snapshot": "snapshot.create",
"POST-/_snapshot/:repository/:snapshot/_restore": "snapshot.restore",
"POST-/_tasks/_cancel": "tasks.cancel",
"POST-/_tasks/:task_id/_cancel": "tasks.cancel",
"POST-/_template/:name": "indices.put_template",
"POST-/_update_by_query/:task_id/_rethrottle": "reindex_rethrottle",
"POST-/_upgrade": "indices.upgrade",
"POST-/_validate/query": "indices.validate_query",
"POST-/:alias/_rollover": "indices.rollover",
"POST-/:alias/_rollover/:new_index": "indices.rollover",
"POST-/:index/_alias/:name": "indices.put_alias",
"POST-/:index/_aliases/:name": "indices.put_alias",
"POST-/:index/_analyze": "indices.analyze",
"POST-/:index/_bulk": "bulk",
"POST-/:index/_cache/clear": "indices.clear_cache",
"POST-/:index/_close": "indices.close",
"POST-/:index/_count": "count",
"POST-/:index/_DELETE-_by_query": "DELETE-_by_query",
"POST-/:index/_doc": "doc.create",
"POST-/:index/_doc/:id": "doc.put",
"POST-/:index/_doc/:id/_update": "doc.update",
"POST-/:index/_field_caps": "field_caps",
"POST-/:index/_flush": "indices.flush",
"POST-/:index/_flush/synced": "indices.flush_synced",
"POST-/:index/_forcemerge": "indices.forcemerge",
"POST/:index/_mget": "mget",
"POST/:index/_msearch": "msearch",
"POST/:index/_msearch/template": "msearch_template",
"POST/:index/_mtermvectors": "mtermvectors",
"POST/:index/_open": "indices.open",
"POST/:index/_rank_eval": "rank_eval",
"POST/:index/_refresh": "indices.refresh",
"POST/:index/_search": "search",
"POST/:index/_search/template": "search_template",
"POST/:index/_search_shards": "search_shards",
"POST/:index/_shrink/:target": "indices.shrink",
"POST/:index/_split/:target": "indices.split",
"POST/:index/_update_by_query": "update_by_query",
"POST/:index/_upgrade": "indices.upgrade",
"POST/:index/_validate/query": "indices.validate_query",
"POST-/:index/_mget": "mget",
"POST-/:index/_msearch": "msearch",
"POST-/:index/_msearch/template": "msearch_template",
"POST-/:index/_mtermvectors": "mtermvectors",
"POST-/:index/_open": "indices.open",
"POST-/:index/_rank_eval": "rank_eval",
"POST-/:index/_refresh": "indices.refresh",
"POST-/:index/_search": "search",
"POST-/:index/_search/template": "search_template",
"POST-/:index/_search_shards": "search_shards",
"POST-/:index/_shrink/:target": "indices.shrink",
"POST-/:index/_split/:target": "indices.split",
"POST-/:index/_update_by_query": "update_by_query",
"POST-/:index/_upgrade": "indices.upgrade",
"POST-/:index/_validate/query": "indices.validate_query",
"POST:index/_mapping": "indices.put_mapping",
"POST:index/_mappings": "indices.put_mapping",
"PUT/_bulk": "bulk",
"PUT/_cluster/settings": "cluster.put_settings",
"PUT/_ingest/pipeline/:id": "ingest.put_pipeline",
"POST-/:index/_mapping": "indices.put_mapping",
"POST-/:index/_mappings": "indices.put_mapping",
"PUT-/_bulk": "bulk",
"PUT-/_cluster/settings": "cluster.put_settings",
"PUT-/_ingest/pipeline/:id": "ingest.put_pipeline",
"PUT/_scripts/:id": "put_script",
"PUT/_scripts/:id/:context": "put_script",
"PUT/_settings": "indices.put_settings",
"PUT/_snapshot/:repository": "snapshot.create_repository",
"PUT/_snapshot/:repository/:snapshot": "snapshot.create",
"PUT/_template/:name": "indices.put_template",
"PUT/:index": "indices.create",
"PUT/:index/_alias/:name": "indices.put_alias",
"PUT/:index/_aliases/:name": "indices.put_alias",
"PUT/:index/_bulk": "bulk",
"PUT/:index/_doc": "index",
"PUT/:index/_doc/:id": "index",
"PUT-/_scripts/:id": "put_script",
"PUT-/_scripts/:id/:context": "put_script",
"PUT-/_settings": "indices.put_settings",
"PUT-/_snapshot/:repository": "snapshot.create_repository",
"PUT-/_snapshot/:repository/:snapshot": "snapshot.create",
"PUT-/_template/:name": "indices.put_template",
"PUT-/:index": "indices.create",
"PUT-/:index/_alias/:name": "indices.put_alias",
"PUT-/:index/_aliases/:name": "indices.put_alias",
"PUT-/:index/_bulk": "bulk",
"PUT-/:index/_doc": "index",
"PUT-/:index/_doc/:id": "index",
"PUT/:index/_settings": "indices.put_settings",
"PUT/:index/_shrink/:target": "indices.shrink",
"PUT/:index/_split/:target": "indices.split",
"PUT-/:index/_settings": "indices.put_settings",
"PUT-/:index/_shrink/:target": "indices.shrink",
"PUT-/:index/_split/:target": "indices.split",
"PUT:index/_mapping": "indices.put_mapping",
"PUT:index/_mappings": "indices.put_mapping"
"PUT-/:index/_mapping": "indices.put_mapping",
"PUT-/:index/_mappings": "indices.put_mapping"
}

View File

@ -4,7 +4,7 @@
"bulk"
],
"cat": [
"*",
"cat.*",
"cat.indices",
"cat.help",
"cat.repositories",
@ -27,7 +27,7 @@
"cat.master"
],
"cluster": [
"*",
"cluster.*",
"cluster.health",
"cluster.get_settings",
"cluster.pending_tasks",
@ -43,14 +43,14 @@
"count"
],
"doc": [
"*",
"doc.*",
"doc.update",
"doc.put",
"doc.create",
"doc.delete"
],
"exists": [
"*",
"exists"
],
"explain": [
@ -63,6 +63,7 @@
"get"
],
"indices": [
"indices.*",
"indices.exists_alias",
"indices.get_alias",
"indices.recovery",
@ -108,6 +109,7 @@
"info"
],
"ingest": [
"ingest.*",
"ingest.delete_pipeline",
"ingest.put_pipeline",
"ingest.simulate",
@ -127,6 +129,7 @@
"mtermvectors"
],
"nodes": [
"nodes.*",
"nodes.info",
"nodes.stats",
"nodes.reload_secure_settings",
@ -149,6 +152,7 @@
"render_search_template"
],
"scripts": [
"scripts.*",
"scripts.get",
"scripts.put",
"scripts.delete"
@ -169,6 +173,7 @@
"search_template"
],
"snapshot": [
"snapshot.*",
"snapshot.get_repository",
"snapshot.create_repository",
"snapshot.create",
@ -180,6 +185,7 @@
"snapshot.get"
],
"source": [
"source.*",
"source.head",
"source.get"
],

View File

@ -95,7 +95,7 @@ func authorize(user Account) (m map[string]interface{}, err error) {
r, _ := GetRole(v.Id)
privilege = append(privilege, r.Platform...)
RolePermission[v.Name] = enum.Role{
RoleMap[v.Name] = Role{
Platform: r.Platform,
Cluster: r.Cluster,
ClusterPrivilege: r.ClusterPrivilege,
@ -231,12 +231,12 @@ func ValidatePermission(claims *UserClaims, permissions []string) (err error) {
err = errors.New("api permission is empty")
return
}
return nil
// 权限校验
userPermissionMap := make(map[string]struct{})
for _, role := range user.Roles {
if _, ok := RolePermission[role]; ok {
for _, v := range RolePermission[role].Platform {
if _, ok := RoleMap[role]; ok {
for _, v := range RoleMap[role].Platform {
userPermissionMap[v] = struct{}{}
//all include read

View File

@ -3,8 +3,6 @@ package biz
import (
"context"
"errors"
httprouter "infini.sh/framework/core/api/router"
"net/http"
)
const ctxUserKey = "user"
@ -23,57 +21,3 @@ func FromUserContext(ctx context.Context) (*User, error) {
}
return reqUser.User, nil
}
type EsRequest struct {
Method string `json:"method"`
Cluster []string `json:"cluster"`
Index []string `json:"index"`
Doc string `json:"doc"`
Path string `json:"path"`
}
func NewEsRequest(r *http.Request, ps httprouter.Params) EsRequest {
//GET elasticsearch/c6dgjtgvi076f32oibj0/index/test/_mappings
clusterId := ps.ByName("id")
index := ps.ByName("index")
doc := ps.ByName("docId")
//如果index存在说明调用的是index api
return EsRequest{
Cluster: []string{clusterId},
Index: []string{index},
Doc: doc,
Path: r.URL.Path,
Method: r.Method,
}
}
func ValidateEsPermission(req EsRequest, userRole Role) (err error) {
userClusterMap := make(map[string]struct{})
userIndexMap := make(map[string]struct{})
for _, v := range userRole.Cluster {
userClusterMap[v.Id] = struct{}{}
}
//todo 启动内存
for _, val := range userRole.Index {
for _, v := range val.Name {
userIndexMap[v] = struct{}{}
}
}
for _, v := range req.Cluster {
if _, ok := userClusterMap[v]; !ok {
err = errors.New("no cluster permission")
return
}
}
for _, v := range req.Index {
if _, ok := userIndexMap[v]; !ok {
err = errors.New("no index permission")
return
}
}
return
}

View File

@ -19,58 +19,19 @@ var AdminPrivilege = []string{
"system.role:read", "system.role:all", "system.user:read", "system.user:all",
}
type Role struct {
Platform []string `json:"platform,omitempty"`
Cluster []struct {
Id string `json:"id"`
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"`
}
var Admin Role
var BuildRoles = make(map[string]map[string]interface{}, 0)
func init() {
Admin = Role{
Platform: AdminPrivilege,
}
UserMenu := Menu{
Id: "system_user",
Privilege: "all",
}
RoleMenu := Menu{
Id: "system_role",
Privilege: "all",
}
AdminMenu := []Menu{
UserMenu, RoleMenu,
}
BuildRoles["admin"] = map[string]interface{}{
"id": "admin",
"name": "管理员",
"permission": AdminMenu,
"platform": []string{"system.role:all", "system.user:all"},
"builtin": true,
"description": "is admin",
"created": time.Now(),
}
BuildRoles["user_admin"] = map[string]interface{}{
"id": "user_admin",
"name": "用户管理员",
"permission": UserMenu,
"builtin": true,
"description": "is user admin",
"created": time.Now(),
}
//自定义角色=》 =》permissionKey
// userrole=> [cluster::all,clust] => permissionValue [cluster::read,cluster::write]
// login=> userrole=> cluster::all =>permissionList[]

View File

@ -1,14 +1,15 @@
package biz
import "infini.sh/console/internal/biz/enum"
import "infini.sh/console/internal/core"
var ClusterApis = make(map[string][]string)
var IndexApis = make([]string, 0)
var RolePermission = make(map[string]enum.Role)
var EsApiMap = make(map[string]string)
var RoleMap = make(map[string]Role)
var EsApiRoutes = core.NewRouter()
type Role struct {
Name string `json:"name"`
Platform []string `json:"platform,omitempty"`
Cluster []struct {
Id string `json:"id"`

View File

@ -129,11 +129,19 @@ func UpdateUser(localUser *User, id string, req dto.UpdateUser) (err error) {
err = ErrNotFound
return
}
roles := make([]rbac.UserRole, 0)
for _, v := range req.Roles {
roles = append(roles, rbac.UserRole{
Id: v.Id,
Name: v.Name,
})
}
changeLog, _ := util.DiffTwoObject(user, req)
user.Name = req.Name
user.Email = req.Email
user.Phone = req.Phone
user.Tags = req.Tags
user.Roles = roles
user.Updated = time.Now()
err = orm.Save(&user)
if err != nil {
@ -150,6 +158,7 @@ func UpdateUser(localUser *User, id string, req dto.UpdateUser) (err error) {
"phone": user.Phone,
"name": user.Name,
"tags": user.Tags,
"roles": roles,
"updated": user.Updated,
},
User: util.MapStr{

112
internal/biz/validate.go Normal file
View File

@ -0,0 +1,112 @@
package biz
import (
"errors"
httprouter "infini.sh/framework/core/api/router"
"net/http"
)
type EsRequest struct {
Method string `json:"method"`
Cluster []string `json:"cluster"`
Index []string `json:"index"`
Doc string `json:"doc"`
Path string `json:"path"`
}
func NewEsRequest(r *http.Request, ps httprouter.Params) EsRequest {
//GET elasticsearch/c6dgjtgvi076f32oibj0/index/test/_mappings
clusterId := ps.ByName("id")
index := ps.ByName("index")
doc := ps.ByName("docId")
//如果index存在说明调用的是index api
return EsRequest{
Cluster: []string{clusterId},
Index: []string{index},
Doc: doc,
Path: r.URL.Path,
Method: r.Method,
}
}
func ValidateEsPermission(req EsRequest, userRole Role) (err error) {
route, err := EsApiRoutes.Handle(req.Method, req.Path)
if err != nil {
return
}
if len(req.Index) > 0 {
err = validateIndex(req, userRole, route)
if err != nil {
return err
}
}
err = validateCluster(req, userRole, route)
return
}
func validateIndex(req EsRequest, userRole Role, route string) (err error) {
userIndexMap := make(map[string]struct{})
privilegeMap := make(map[string]struct{})
for _, val := range userRole.Index {
for _, v := range val.Name {
userIndexMap[v] = struct{}{}
}
for _, v := range val.Privilege {
privilegeMap[v] = struct{}{}
}
}
for _, v := range req.Index {
if _, ok := userIndexMap[v]; !ok {
err = errors.New("no index permission")
return
}
}
if _, ok := privilegeMap[route]; !ok {
err = errors.New("no index api permission")
return
}
return
}
func validateCluster(req EsRequest, userRole Role, route string) (err error) {
userClusterMap := make(map[string]struct{})
for _, v := range userRole.Cluster {
userClusterMap[v.Id] = struct{}{}
}
for _, v := range req.Cluster {
if _, ok := userClusterMap[v]; !ok {
err = errors.New("no cluster permission")
return
}
}
tmp := make([]string, 0)
for _, val := range userRole.ClusterPrivilege {
for _, v := range val {
tmp = append(tmp, v...)
}
}
for _, v := range tmp {
if v == route {
return nil
}
}
return errors.New("no cluster api permission")
}
func CombineUserRoles(roleNames []string) Role {
newRole := Role{}
for _, v := range roleNames {
r := RoleMap[v]
newRole.Cluster = append(newRole.Cluster, r.Cluster...)
newRole.Platform = append(newRole.Platform, r.Platform...)
newRole.Index = append(newRole.Index, r.Index...)
newRole.ClusterPrivilege = append(newRole.ClusterPrivilege, r.ClusterPrivilege...)
}
return newRole
}

94
internal/core/router.go Normal file
View File

@ -0,0 +1,94 @@
package core
import (
"errors"
"strings"
)
type Router struct {
roots map[string]*node
handlers map[string]string
}
func NewRouter() *Router {
return &Router{
roots: make(map[string]*node),
handlers: make(map[string]string),
}
}
// Only one * is allowed
func parsePattern(pattern string) []string {
vs := strings.Split(pattern, "/")
parts := make([]string, 0)
for _, item := range vs {
if item != "" {
parts = append(parts, item)
if item[0] == '*' {
break
}
}
}
return parts
}
func (r *Router) AddRoute(method string, pattern string, handler string) {
parts := parsePattern(pattern)
key := method + "-" + pattern
_, ok := r.roots[method]
if !ok {
r.roots[method] = &node{}
}
r.roots[method].insert(pattern, parts, 0)
r.handlers[key] = handler
}
func (r *Router) GetRoute(method string, path string) (*node, map[string]string) {
searchParts := parsePattern(path)
params := make(map[string]string)
root, ok := r.roots[method]
if !ok {
return nil, nil
}
n := root.search(searchParts, 0)
if n != nil {
parts := parsePattern(n.pattern)
for index, part := range parts {
if part[0] == ':' {
params[part[1:]] = searchParts[index]
}
//if part[0] == '*' && len(part) > 1 {
// params[part[1:]] = strings.Join(searchParts[index:], "/")
// break
//}
}
return n, params
}
return nil, nil
}
func (r *Router) getRoutes(method string) []*node {
root, ok := r.roots[method]
if !ok {
return nil
}
nodes := make([]*node, 0)
root.travel(&nodes)
return nodes
}
func (r *Router) Handle(method string, path string) (handle string, err error) {
n, _ := r.GetRoute(method, path)
if n == nil {
err = errors.New("router not match")
return
}
return r.handlers[method+"-"+n.pattern], nil
}

View File

@ -0,0 +1,79 @@
package core
import (
"fmt"
"reflect"
"testing"
)
func newTestRouter() *Router {
r := NewRouter()
//GET "GET/_mapping/:index": "indices.get_mapping",
r.AddRoute("GET", "/:index/_mappings", "indices.get_mapping")
r.AddRoute("GET", "/hello/:name", "gethello")
r.AddRoute("GET", "/hello/b/c", "hellobc")
r.AddRoute("GET", "/hi/:name", "getHi")
r.AddRoute("GET", "/role/xushuhui", "getRole")
return r
}
func TestParsePattern(t *testing.T) {
ok := reflect.DeepEqual(parsePattern("/p/:name"), []string{"p", ":name"})
ok = ok && reflect.DeepEqual(parsePattern("/p/*"), []string{"p", "*"})
ok = ok && reflect.DeepEqual(parsePattern("/p/*name/*"), []string{"p", "*name"})
if !ok {
t.Fatal("test parsePattern failed")
}
}
func TestGetRoute(t *testing.T) {
//r := newTestRouter()
//path := "/elasticsearch/c6dgjtgvi076f32oibj0/index/test/_mappings"
//paths := strings.Split(path, "/")
//newPath := "/" + strings.Join(paths[4:], "/")
//t.Log(newPath)
//if n == nil {
// t.Fatal("nil shouldn't be returned")
//}
//if n.pattern != "/hello/:name" {
// t.Fatal("should match /hello/:name")
//}
//
//if ps["name"] != "geektutu" {
// t.Fatal("name should be equal to 'geektutu'")
//}
//fmt.Printf("matched path: %s, params['name']: %s\n", n.pattern, ps["name"])
}
func TestGetRoute2(t *testing.T) {
r := newTestRouter()
n1, ps1 := r.GetRoute("GET", "/assets/file1.txt")
ok1 := n1.pattern == "/assets/*filepath" && ps1["filepath"] == "file1.txt"
if !ok1 {
t.Fatal("pattern shoule be /assets/*filepath & filepath shoule be file1.txt")
}
n2, ps2 := r.GetRoute("GET", "/assets/css/test.css")
ok2 := n2.pattern == "/assets/*filepath" && ps2["filepath"] == "css/test.css"
if !ok2 {
t.Fatal("pattern shoule be /assets/*filepath & filepath shoule be css/test.css")
}
}
func TestGetRoutes(t *testing.T) {
r := newTestRouter()
nodes := r.getRoutes("GET")
for i, n := range nodes {
fmt.Println(i+1, n)
}
if len(nodes) != 5 {
t.Fatal("the number of routes shoule be 4")
}
}

83
internal/core/trie.go Normal file
View File

@ -0,0 +1,83 @@
package core
import (
"fmt"
"strings"
)
type node struct {
pattern string // 待匹配路由,例如 /p/:lang
part string // 路由中的一部分,例如 :lang
children []*node // 子节点,例如 [doc, tutorial, intro]
isWild bool // 是否精确匹配part 含有 : 或 * 时为true
}
func (n *node) String() string {
return fmt.Sprintf("node{pattern=%s, part=%s, isWild=%t}", n.pattern, n.part, n.isWild)
}
func (n *node) insert(pattern string, parts []string, height int) {
if len(parts) == height {
n.pattern = pattern
return
}
part := parts[height]
child := n.matchChild(part)
if child == nil {
child = &node{part: part, isWild: part[0] == ':' || part[0] == '*'}
n.children = append(n.children, child)
}
child.insert(pattern, parts, height+1)
}
func (n *node) search(parts []string, height int) *node {
if len(parts) == height || strings.HasPrefix(n.part, "*") {
if n.pattern == "" {
return nil
}
return n
}
part := parts[height]
children := n.matchChildren(part)
for _, child := range children {
result := child.search(parts, height+1)
if result != nil {
return result
}
}
return nil
}
func (n *node) travel(list *[]*node) {
if n.pattern != "" {
*list = append(*list, n)
}
for _, child := range n.children {
child.travel(list)
}
}
// 第一个匹配成功的节点,用于插入
func (n *node) matchChild(part string) *node {
for _, child := range n.children {
if child.part == part || child.isWild {
return child
}
}
return nil
}
// 所有匹配成功的节点,用于查找
func (n *node) matchChildren(part string) []*node {
nodes := make([]*node, 0)
for _, child := range n.children {
if child.part == part || child.isWild {
nodes = append(nodes, child)
}
}
return nodes
}

View File

@ -1,14 +1,5 @@
package dto
type RolePermission struct {
Api []string `json:"api"`
Menu []Menu `json:"menu"`
}
type Menu struct {
Id string `json:"id"`
Name string `json:"name"`
Privilege string `json:"privilege"`
}
type UpdateRole struct {
Description string `json:"description" `
Platform []string `json:"platform"`
@ -42,6 +33,7 @@ type UpdateUser struct {
Email string `json:"email"`
Phone string `json:"phone"`
Tags []string `json:"tags"`
Roles []Role `json:"roles"`
}
type UpdateUserRole struct {
Roles []Role `json:"roles"`

View File

@ -22,16 +22,22 @@ func LoginRequired(h httprouter.Handle) httprouter.Handle {
func EsPermissionRequired(h httprouter.Handle) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
//req := biz.NewEsRequest(r, ps)
//err := biz.ValidateEsPermission(req)
//if err != nil {
// w = handleError(w, http.StatusForbidden, err)
// return
//}
claims, err := biz.ValidateLogin(r.Header.Get("Authorization"))
if err != nil {
w = handleError(w, http.StatusUnauthorized, err)
return
}
req := biz.NewEsRequest(r, ps)
newRole := biz.CombineUserRoles(claims.Roles)
err = biz.ValidateEsPermission(req, newRole)
if err != nil {
w = handleError(w, http.StatusForbidden, err)
return
}
h(w, r, ps)
}
}
func PermissionRequired(h httprouter.Handle, permissions ...string) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
claims, err := biz.ValidateLogin(r.Header.Get("Authorization"))

View File

@ -9,6 +9,7 @@ import (
"infini.sh/console/model/gateway"
"infini.sh/console/model/rbac"
_ "infini.sh/console/plugin"
rbacApi "infini.sh/console/plugin/api/rbac"
alerting2 "infini.sh/console/service/alerting"
"infini.sh/framework"
"infini.sh/framework/core/elastic"
@ -137,7 +138,7 @@ func main() {
if err != nil {
log.Errorf("init alerting task error: %v", err)
}
rbacApi.Init()
}()
}, nil) {

View File

@ -6,9 +6,13 @@ import (
"infini.sh/console/internal/biz/enum"
m "infini.sh/console/internal/middleware"
"infini.sh/framework/core/api"
"infini.sh/framework/core/elastic"
"infini.sh/framework/core/util"
"os"
"path"
log "src/github.com/cihub/seelog"
"src/github.com/mitchellh/mapstructure"
"strings"
)
type Rbac struct {
@ -49,47 +53,47 @@ func loadJsonConfig() {
biz.IndexApis = apis["indices"]
delete(apis, "indices")
biz.ClusterApis = apis
//bytes, err = util.FileGetContent(path.Join(pwd, "/config/map.json"))
//if err != nil {
// panic("load json file err " + err.Error())
//
//}
//
//err = json.Unmarshal(bytes, &biz.EsApiMap)
//if err != nil {
// panic("json config unmarshal err " + err.Error())
//}
bytes, err = util.FileGetContent(path.Join(pwd, "/config/map.json"))
if err != nil {
panic("load json file err " + err.Error())
}
esapiMap := make(map[string]string)
err = json.Unmarshal(bytes, &esapiMap)
if err != nil {
panic("json config unmarshal err " + err.Error())
}
for k, v := range esapiMap {
s := strings.Split(k, "-")
biz.EsApiRoutes.AddRoute(s[0], s[1], v)
}
}
func loadRolePermission() {
biz.RolePermission = make(map[string]enum.Role)
biz.RoleMap = make(map[string]biz.Role)
biz.RolePermission["admin"] = enum.Admin
biz.RoleMap["admin"] = biz.Role{
Platform: enum.AdminPrivilege,
}
res, err := biz.SearchRole("", 0, 100)
if err != nil {
log.Error(err)
return
}
response := elastic.SearchResponse{}
util.FromJSONBytes(res.Raw, &response)
for _, v := range response.Hits.Hits {
var role biz.Role
err = mapstructure.Decode(v.Source, &role)
if err != nil {
return
}
biz.RoleMap[role.Name] = role
}
}
func Init() {
loadJsonConfig()
loadRolePermission()
}
func existInternalUser() {
//user, err := biz.GetUser("admin")
//if errors.Is(err, elastic.ErrNotFound) {
// user.ID = "admin"
// user.Username = "admin"
// hash, _ := bcrypt.GenerateFromPassword([]byte("admin"), bcrypt.DefaultCost)
//
// user.Password = string(hash)
// user.Email = ""
// user.Phone = ""
// user.Name = ""
//
//
// user.Created = time.Now()
// user.Updated = time.Now()
//
//}
}
func existInternalRole() {
}