fabaccess-bffh/bffhd/authorization/mod.rs

37 lines
799 B
Rust
Raw Normal View History

2022-03-12 17:31:53 +01:00
use std::sync::Arc;
use crate::authorization::permissions::Permission;
use crate::authorization::roles::Role;
2022-03-15 16:28:11 +01:00
use crate::Users;
2022-03-12 17:31:53 +01:00
use crate::users::User;
2022-03-10 20:52:34 +01:00
pub mod permissions;
2022-03-12 17:31:53 +01:00
pub mod roles;
struct Inner {
2022-03-15 16:28:11 +01:00
users: Users,
2022-03-12 17:31:53 +01:00
}
impl Inner {
2022-03-15 16:28:11 +01:00
pub fn new(users: Users) -> Self {
Self { users }
2022-03-12 17:31:53 +01:00
}
}
#[derive(Clone)]
pub struct AuthorizationHandle {
2022-03-15 16:28:11 +01:00
users: Users,
2022-03-12 17:31:53 +01:00
}
impl AuthorizationHandle {
2022-03-15 16:28:11 +01:00
pub fn new(users: Users) -> Self {
Self { users }
2022-03-12 17:31:53 +01:00
}
2022-03-13 22:50:37 +01:00
pub fn get_user_roles(&self, uid: impl AsRef<str>) -> Option<impl IntoIterator<Item=Role>> {
2022-03-15 16:28:11 +01:00
let user = self.users.get_user(uid.as_ref())?;
2022-03-13 22:50:37 +01:00
Some([])
2022-03-12 17:31:53 +01:00
}
pub fn is_permitted<'a>(&self, roles: impl IntoIterator<Item=&'a Role>, perm: impl AsRef<Permission>) -> bool {
unimplemented!()
}
}