fabaccess-bffh/bffhd/authorization/mod.rs

23 lines
487 B
Rust
Raw Permalink Normal View History

2022-05-05 15:50:44 +02:00
use crate::authorization::roles::Roles;
2022-03-15 16:28:11 +01:00
use crate::Users;
2022-03-15 20:00:43 +01:00
2022-03-10 20:52:34 +01:00
pub mod permissions;
2022-03-12 17:31:53 +01:00
pub mod roles;
#[derive(Clone)]
pub struct AuthorizationHandle {
2022-03-15 16:28:11 +01:00
users: Users,
2022-03-15 17:52:47 +01:00
roles: Roles,
2022-03-12 17:31:53 +01:00
}
impl AuthorizationHandle {
2022-03-15 17:52:47 +01:00
pub fn new(users: Users, roles: Roles) -> Self {
Self { users, roles }
2022-03-12 17:31:53 +01:00
}
2022-03-15 17:52:47 +01:00
pub fn get_user_roles(&self, uid: impl AsRef<str>) -> Option<Vec<String>> {
2022-03-15 16:28:11 +01:00
let user = self.users.get_user(uid.as_ref())?;
2022-03-15 17:52:47 +01:00
Some(user.userdata.roles.clone())
2022-03-12 17:31:53 +01:00
}
2022-05-05 15:50:44 +02:00
}