Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/ee-repo-ref.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0d72102809e766d5285a162dcc30055847700ee2
a61644247e621f863a2a72626f47ee1c13267c49
14 changes: 11 additions & 3 deletions backend/windmill-api/src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ pub fn global_service() -> Router {
.route("/overwrite", post(overwrite_igroups))
}

/// Normalize group names: replace spaces with underscores and convert to lowercase
/// Used when manually creating groups and SCIM-managed groups
pub fn convert_name(name: &str) -> String {
name.replace(" ", "_").to_lowercase()
}

#[derive(FromRow, Serialize, Deserialize)]
pub struct Group {
pub workspace_id: String,
Expand Down Expand Up @@ -291,10 +297,12 @@ async fn create_igroup(
require_super_admin(&db, &authed.email).await?;
let mut tx = db.begin().await?;

let normalized_name = convert_name(&ng.name);

let id = Uuid::new_v4().to_string();
sqlx::query!(
"INSERT INTO instance_group (name, summary, id) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING",
ng.name,
normalized_name,
ng.summary,
id,
)
Expand All @@ -307,13 +315,13 @@ async fn create_igroup(
"igroup.create",
ActionKind::Create,
"global",
Some(&ng.name.to_string()),
Some(&normalized_name),
None,
)
.await?;

tx.commit().await?;
Ok(format!("Created group {}", ng.name))
Ok(format!("Created group {}", normalized_name))
}

#[derive(Deserialize)]
Expand Down
Loading