fix(ui): проверять права каждого источника дашборда
This commit is contained in:
1 parent
1999e8160e
commit
587dd94f82
7 files changed
+59
-5
No files matched your search
@@ -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("Неизвестный источник дашборда")
|
||||
}
|
||||
Reference in new issue
Block a user