98 lines
3.2 KiB
Python
98 lines
3.2 KiB
Python
#!/usr/bin/env python3
|
|
"""FOMS RBAC permission registration"""
|
|
import os, sys
|
|
|
|
# Find Sage root for set_role_perm.py
|
|
sage_root = None
|
|
for c in [os.path.expanduser("~/repos/sage"), os.path.expanduser("~/test/sage")]:
|
|
if os.path.isdir(os.path.join(c, "py3", "bin")):
|
|
sage_root = c
|
|
break
|
|
if not sage_root:
|
|
print("ERROR: Sage root not found")
|
|
sys.exit(1)
|
|
|
|
sys.path.insert(0, os.path.join(sage_root, "py3", "bin"))
|
|
|
|
from set_role_perm import set_path_perm
|
|
|
|
# Paths accessible without login
|
|
PATHS_ANY = [
|
|
"/",
|
|
"/index.ui",
|
|
"/api/login.dspy",
|
|
]
|
|
|
|
# Paths requiring authentication
|
|
PATHS_LOGINED = [
|
|
"/api/clusters_create.dspy",
|
|
"/api/clusters_update.dspy",
|
|
"/api/clusters_delete.dspy",
|
|
"/api/nodes_create.dspy",
|
|
"/api/nodes_update.dspy",
|
|
"/api/nodes_delete.dspy",
|
|
"/api/sync_databases_create.dspy",
|
|
"/api/sync_databases_update.dspy",
|
|
"/api/sync_databases_delete.dspy",
|
|
"/api/sync_directories_create.dspy",
|
|
"/api/sync_directories_update.dspy",
|
|
"/api/sync_directories_delete.dspy",
|
|
"/api/agent_heartbeat.dspy",
|
|
"/api/agent_report_health.dspy",
|
|
"/api/trigger_switchover.dspy",
|
|
"/api/trigger_switchback.dspy",
|
|
"/api/dashboard_stats.dspy",
|
|
# CRUD list pages
|
|
"/clusters_list",
|
|
"/clusters_list/index.ui",
|
|
"/nodes_list",
|
|
"/nodes_list/index.ui",
|
|
"/sync_databases_list",
|
|
"/sync_databases_list/index.ui",
|
|
"/sync_directories_list",
|
|
"/sync_directories_list/index.ui",
|
|
# CRUD generated files
|
|
"/clusters_list/get_clusters_list.dspy",
|
|
"/clusters_list/add_clusters_list.dspy",
|
|
"/clusters_list/update_clusters_list.dspy",
|
|
"/clusters_list/delete_clusters_list.dspy",
|
|
"/nodes_list/get_nodes_list.dspy",
|
|
"/nodes_list/add_nodes_list.dspy",
|
|
"/nodes_list/update_nodes_list.dspy",
|
|
"/nodes_list/delete_nodes_list.dspy",
|
|
"/sync_databases_list/get_sync_databases_list.dspy",
|
|
"/sync_databases_list/add_sync_databases_list.dspy",
|
|
"/sync_databases_list/update_sync_databases_list.dspy",
|
|
"/sync_databases_list/delete_sync_databases_list.dspy",
|
|
"/sync_directories_list/get_sync_directories_list.dspy",
|
|
"/sync_directories_list/add_sync_directories_list.dspy",
|
|
"/sync_directories_list/update_sync_directories_list.dspy",
|
|
"/sync_directories_list/delete_sync_directories_list.dspy",
|
|
# Metrics & logs
|
|
"/api/agent_report_metrics.dspy",
|
|
"/api/agent_push_logs.dspy",
|
|
"/api/node_detail.dspy",
|
|
"/api/node_metrics_history.dspy",
|
|
# Remote command
|
|
"/api/exec_remote_command.dspy",
|
|
"/api/agent_poll_commands.dspy",
|
|
"/api/agent_report_command_result.dspy",
|
|
]
|
|
|
|
# Agent heartbeat endpoint: no auth (agents use token)
|
|
PATHS_ANY.append("/api/agent_heartbeat.dspy")
|
|
PATHS_ANY.append("/api/agent_report_health.dspy")
|
|
PATHS_ANY.append("/api/agent_report_metrics.dspy")
|
|
PATHS_ANY.append("/api/agent_push_logs.dspy")
|
|
PATHS_ANY.append("/api/agent_poll_commands.dspy")
|
|
PATHS_ANY.append("/api/agent_report_command_result.dspy")
|
|
|
|
if __name__ == '__main__':
|
|
for p in PATHS_ANY:
|
|
set_path_perm("any", p)
|
|
print(f" any {p}")
|
|
for p in PATHS_LOGINED:
|
|
set_path_perm("logined", p)
|
|
print(f" logined {p}")
|
|
print("Done. Restart FOMS to apply.")
|