13 lines
983 B
TypeScript
13 lines
983 B
TypeScript
/** 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("Неизвестный источник дашборда")
|
|
}
|