Can determine the rights of the token over the group
This commit is contained in:
parent
a8a75328a9
commit
26fee59c5d
@ -66,16 +66,16 @@ pub async fn rights() -> HttpResult {
|
|||||||
let group_vms = virtweb_client::group_vm_info(&g).await?;
|
let group_vms = virtweb_client::group_vm_info(&g).await?;
|
||||||
|
|
||||||
res.groups.push(GroupInfo {
|
res.groups.push(GroupInfo {
|
||||||
id: g,
|
id: g.clone(),
|
||||||
vms: group_vms,
|
vms: group_vms,
|
||||||
can_get_state: false, //TODO
|
can_get_state: rights.is_route_allowed("GET", &g.route_vm_state(None)),
|
||||||
can_start: false,
|
can_start: rights.is_route_allowed("GET", &g.route_vm_start(None)),
|
||||||
can_shutdown: false,
|
can_shutdown: rights.is_route_allowed("GET", &g.route_vm_shutdown(None)),
|
||||||
can_kill: false,
|
can_kill: rights.is_route_allowed("GET", &g.route_vm_kill(None)),
|
||||||
can_reset: false,
|
can_reset: rights.is_route_allowed("GET", &g.route_vm_reset(None)),
|
||||||
can_suspend: false,
|
can_suspend: rights.is_route_allowed("GET", &g.route_vm_suspend(None)),
|
||||||
can_resume: false,
|
can_resume: rights.is_route_allowed("GET", &g.route_vm_resume(None)),
|
||||||
can_screenshot: false,
|
can_screenshot: rights.is_route_allowed("GET", &g.route_vm_screenshot(None)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,87 @@ impl GroupID {
|
|||||||
pub fn route_vm_info(&self) -> String {
|
pub fn route_vm_info(&self) -> String {
|
||||||
format!("/api/group/{}/vm/info", self.0)
|
format!("/api/group/{}/vm/info", self.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn route_vm_state(&self, vm: Option<VMUuid>) -> String {
|
||||||
|
format!(
|
||||||
|
"/api/group/{}/vm/state{}",
|
||||||
|
self.0,
|
||||||
|
match vm {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(id) => format!("?vm_id={}", id.0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pub fn route_vm_start(&self, vm: Option<VMUuid>) -> String {
|
||||||
|
format!(
|
||||||
|
"/api/group/{}/vm/start{}",
|
||||||
|
self.0,
|
||||||
|
match vm {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(id) => format!("?vm_id={}", id.0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pub fn route_vm_shutdown(&self, vm: Option<VMUuid>) -> String {
|
||||||
|
format!(
|
||||||
|
"/api/group/{}/vm/shutdown{}",
|
||||||
|
self.0,
|
||||||
|
match vm {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(id) => format!("?vm_id={}", id.0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pub fn route_vm_suspend(&self, vm: Option<VMUuid>) -> String {
|
||||||
|
format!(
|
||||||
|
"/api/group/{}/vm/suspend{}",
|
||||||
|
self.0,
|
||||||
|
match vm {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(id) => format!("?vm_id={}", id.0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pub fn route_vm_resume(&self, vm: Option<VMUuid>) -> String {
|
||||||
|
format!(
|
||||||
|
"/api/group/{}/vm/resume{}",
|
||||||
|
self.0,
|
||||||
|
match vm {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(id) => format!("?vm_id={}", id.0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pub fn route_vm_kill(&self, vm: Option<VMUuid>) -> String {
|
||||||
|
format!(
|
||||||
|
"/api/group/{}/vm/kill{}",
|
||||||
|
self.0,
|
||||||
|
match vm {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(id) => format!("?vm_id={}", id.0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pub fn route_vm_reset(&self, vm: Option<VMUuid>) -> String {
|
||||||
|
format!(
|
||||||
|
"/api/group/{}/vm/reset{}",
|
||||||
|
self.0,
|
||||||
|
match vm {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(id) => format!("?vm_id={}", id.0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pub fn route_vm_screenshot(&self, vm: Option<VMUuid>) -> String {
|
||||||
|
format!(
|
||||||
|
"/api/group/{}/vm/screenshot{}",
|
||||||
|
self.0,
|
||||||
|
match vm {
|
||||||
|
None => "".to_string(),
|
||||||
|
Some(id) => format!("?vm_id={}", id.0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Debug, Copy, Clone, serde::Serialize, serde::Deserialize)]
|
#[derive(Eq, PartialEq, Debug, Copy, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user