use std::sync::Arc; use crate::authorization::permissions::Permission; use crate::authorization::roles::{Role, Roles}; use crate::Users; use crate::users::UserRef; pub mod permissions; pub mod roles; #[derive(Clone)] pub struct AuthorizationHandle { users: Users, roles: Roles, } impl AuthorizationHandle { pub fn new(users: Users, roles: Roles) -> Self { Self { users, roles } } pub fn get_user_roles(&self, uid: impl AsRef) -> Option> { let user = self.users.get_user(uid.as_ref())?; Some(user.userdata.roles.clone()) } pub fn is_permitted<'a>(&self, roles: impl IntoIterator, perm: impl AsRef) -> bool { unimplemented!() } }