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
187 changes: 187 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/defguard_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ bytes = { workspace = true }
ed25519-dalek = { version = "2.2", features = ["rand_core"] }
tower = "0.5"
regex = "1.10"
ammonia = "4.1.1"

[dev-dependencies]
bytes = "1.6"
Expand Down
20 changes: 20 additions & 0 deletions crates/defguard_core/src/handlers/openid_clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ pub async fn add_openid_client(
"User {} adding OpenID client {}",
session.user.username, data.name
);
if ammonia::is_html(&data.name) {
warn!(
"User {} attempted to create openid client with name containing HTML: {}",
session.user.username, data.name
);
return Ok(ApiResponse {
json: json!({"msg": "invalid name"}),
status: StatusCode::BAD_REQUEST,
});
}
let client = OAuth2Client::from_new(data).save(&appstate.pool).await?;
info!(
"User {} added OpenID client {}",
Expand Down Expand Up @@ -89,6 +99,16 @@ pub async fn change_openid_client(
"User {} updating OpenID client {client_id}...",
session.user.username
);
if ammonia::is_html(&data.name) {
warn!(
"User {} attempted to edit openid client with name containing HTML: {}",
session.user.username, data.name
);
return Ok(ApiResponse {
json: json!({"msg": "invalid name"}),
status: StatusCode::BAD_REQUEST,
});
}
let mut transaction = appstate.pool.begin().await?;
let status = match OAuth2Client::find_by_client_id(&mut *transaction, &client_id).await? {
Some(mut client) => {
Expand Down
Loading