mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 19:22:26 +00:00
Add member search to user store
This commit is contained in:
@@ -24,6 +24,7 @@ pub trait AuthenticationProvider: Send + Sync + 'static {
|
|||||||
|
|
||||||
async fn add_membership(&self, principal: &str, member_of: &str) -> Result<(), Error>;
|
async fn add_membership(&self, principal: &str, member_of: &str) -> Result<(), Error>;
|
||||||
async fn remove_membership(&self, principal: &str, member_of: &str) -> Result<(), Error>;
|
async fn remove_membership(&self, principal: &str, member_of: &str) -> Result<(), Error>;
|
||||||
|
async fn list_members(&self, principal: &str) -> Result<Vec<String>, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use middleware::AuthenticationMiddleware;
|
pub use middleware::AuthenticationMiddleware;
|
||||||
|
|||||||
@@ -249,4 +249,18 @@ impl AuthenticationProvider for SqlitePrincipalStore {
|
|||||||
.map_err(crate::Error::from)?;
|
.map_err(crate::Error::from)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
|
async fn list_members(&self, principal: &str) -> Result<Vec<String>, Error> {
|
||||||
|
Ok(sqlx::query!(
|
||||||
|
r#"SELECT principal FROM memberships WHERE member_of = ?"#,
|
||||||
|
principal
|
||||||
|
)
|
||||||
|
.fetch_all(&self.db)
|
||||||
|
.await
|
||||||
|
.map_err(crate::Error::from)?
|
||||||
|
.into_iter()
|
||||||
|
.map(|record| record.principal)
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user