fix(sso): improve handling of filters for get groups for sso

This commit is contained in:
Ruben Fiszel
2024-02-14 13:12:13 +01:00
parent 6c809c3e9e
commit e36995c739
+9 -1
View File
@@ -342,7 +342,7 @@ pub async fn get_groups(
Extension(db): Extension<DB>,
Query(query): Query<ScimQuery>,
) -> Result<JsonScim<serde_json::Value>> {
let sqlb = SqlBuilder::select_from("instance_group")
let mut sqlb = SqlBuilder::select_from("instance_group")
.fields(&[
"name",
"external_id",
@@ -357,6 +357,14 @@ pub async fn get_groups(
.offset(query.startIndex.map(|x| x - 1).unwrap_or(0))
.clone();
if let Some(filter) = query.filter {
let filter = filter
.replace("displayName", "scim_display_name")
.replace("eq", "=")
.replace("\"", "'");
sqlb.and_where(&filter);
}
let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?;
let groups = sqlx::query_as::<_, Group>(&sql)
.fetch_all(&db)