Some preparations for supporting principal memberships

This commit is contained in:
Lennart
2025-02-02 11:34:10 +01:00
parent 93d16f02d9
commit 031d94c9d1
18 changed files with 54 additions and 27 deletions

View File

@@ -8,6 +8,7 @@ use serde::{Deserialize, Serialize};
use std::future::{ready, Ready};
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct User {
pub id: String,
pub displayname: Option<String>,
@@ -16,6 +17,18 @@ pub struct User {
pub app_tokens: Vec<String>,
}
impl User {
/// Returns true if the user is either
/// - the principal itself
/// - has full access to the prinicpal (is member)
pub fn is_principal(&self, principal: &str) -> bool {
if self.id == principal {
return true;
}
false
}
}
#[derive(Clone, Debug, Display)]
pub struct UnauthorizedError;