mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-22 23:07:56 +01:00
parent
728c33f444
commit
58f40d98ed
@ -27,6 +27,10 @@ impl Roles {
|
|||||||
self.roles.get(roleid)
|
self.roles.get(roleid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn list(&self) -> impl Iterator<Item = &String> {
|
||||||
|
self.roles.keys()
|
||||||
|
}
|
||||||
|
|
||||||
/// Tally a role dependency tree into a set
|
/// Tally a role dependency tree into a set
|
||||||
///
|
///
|
||||||
/// A Default implementation exists which adapter may overwrite with more efficient
|
/// A Default implementation exists which adapter may overwrite with more efficient
|
||||||
|
@ -1,13 +1,38 @@
|
|||||||
use api::permissionsystem_capnp::permission_system::info::Server as PermissionSystem;
|
use crate::authorization::roles::Role;
|
||||||
|
use crate::Roles;
|
||||||
|
use api::permissionsystem_capnp::permission_system::info::{
|
||||||
|
GetRoleListParams, GetRoleListResults, Server as PermissionSystem,
|
||||||
|
};
|
||||||
|
use capnp::capability::Promise;
|
||||||
|
use capnp::Error;
|
||||||
|
|
||||||
use crate::session::SessionHandle;
|
use crate::session::SessionHandle;
|
||||||
|
|
||||||
pub struct Permissions;
|
pub struct Permissions {
|
||||||
|
roles: Roles,
|
||||||
|
}
|
||||||
|
|
||||||
impl Permissions {
|
impl Permissions {
|
||||||
pub fn new(_session: SessionHandle) -> Self {
|
pub fn new(session: SessionHandle) -> Self {
|
||||||
Self
|
Self {
|
||||||
|
roles: session.roles,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PermissionSystem for Permissions {}
|
impl PermissionSystem for Permissions {
|
||||||
|
fn get_role_list(
|
||||||
|
&mut self,
|
||||||
|
_: GetRoleListParams,
|
||||||
|
mut results: GetRoleListResults,
|
||||||
|
) -> Promise<(), Error> {
|
||||||
|
let roles = self.roles.list().collect::<Vec<&String>>();
|
||||||
|
let mut builder = results.get();
|
||||||
|
let mut b = builder.init_role_list(roles.len() as u32);
|
||||||
|
for (i, role) in roles.into_iter().enumerate() {
|
||||||
|
let mut role_builder = b.reborrow().get(i as u32);
|
||||||
|
role_builder.set_name(role);
|
||||||
|
}
|
||||||
|
Promise::ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user