mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-23 23:27:57 +01:00
33 lines
959 B
Rust
33 lines
959 B
Rust
use capnp_rpc::CapabilityServerSet;
|
|
use crate::authorization::permissions::Permission;
|
|
use api::auth_capnp::response::successful::Builder;
|
|
use api::role_capnp;
|
|
|
|
use crate::capnp::machinesystem::Machines;
|
|
use crate::capnp::permissionsystem::Permissions;
|
|
use crate::capnp::role::Role;
|
|
use crate::capnp::user_system::Users;
|
|
use crate::session::SessionHandle;
|
|
|
|
pub struct APISession;
|
|
|
|
impl APISession {
|
|
pub fn new() -> Self {
|
|
Self
|
|
}
|
|
|
|
pub fn build(session: SessionHandle, builder: Builder) {
|
|
let mut builder = builder.init_session();
|
|
|
|
builder.reborrow().set_resources(capnp_rpc::new_client(Machines::new(session.clone())));
|
|
|
|
if session.has_perm(Permission::new("bffh.users.manage"))
|
|
{
|
|
let u = Users::new(session.clone());
|
|
builder.reborrow().set_users(capnp_rpc::new_client(u.clone()));
|
|
}
|
|
|
|
builder.set_permissions(capnp_rpc::new_client(Permissions::new(session)));
|
|
}
|
|
}
|