fix(ui): проверять права каждого источника дашборда

This commit is contained in:
Denozordec committed 2026-10-03 19:38:30 +07:00
1 parent 1999e8160e
commit 587dd94f82
7 files changed
+59 -5

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
/** Limited to API paths consumed by useDashboardLive; matches backend request gates. */
export function dashboardRequestPermission(method:string,path:string):string{
const pathname=path.split("?")[0],write=method.toUpperCase()!=="GET"
if(pathname.startsWith("/api/servers"))return write?"mm:servers:write":"mm:servers:read"
if(pathname.startsWith("/api/uptime"))return write?"mm:uptime:write":"mm:uptime:read"
if(pathname.startsWith("/api/filters"))return write?"mm:filters:write":"mm:filters:read"
if(pathname.startsWith("/api/bgp"))return write?"mm:bgp:write":"mm:bgp:read"
if(pathname.startsWith("/api/traffic"))return write?"mm:traffic:write":"mm:traffic:read"
if(pathname.startsWith("/api/internet-path")||pathname.startsWith("/api/wireguard"))return write?"mm:network:write":"mm:network:read"
if(!write&&(pathname==="/api/vxlan"||pathname.startsWith("/api/events")))return "mm:dashboard:read"
throw Error("Неизвестный источник дашборда")
}