From d8ec9615897746b0cae7997ab32f59479922db8c Mon Sep 17 00:00:00 2001 From: Olivia Lee Date: Sat, 19 Jul 2025 15:08:11 -0700 Subject: [PATCH] Bump ruma to e8b0876dda083433a7f9181d47d0aff5a5e05497 (auth check return type change) --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 2 +- src/api/client_server/membership.rs | 9 +-------- src/service/rooms/event_handler.rs | 23 +++++------------------ src/service/rooms/timeline.rs | 22 +++++++--------------- 5 files changed, 25 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd93a4d6..7569469c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2442,7 +2442,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.12.1" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "assign", "js_int", @@ -2461,7 +2461,7 @@ dependencies = [ [[package]] name = "ruma-appservice-api" version = "0.12.1" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "js_int", "ruma-common", @@ -2473,7 +2473,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.20.1" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "as_variant", "assign", @@ -2496,7 +2496,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.15.1" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "as_variant", "base64", @@ -2527,7 +2527,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.30.1" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "as_variant", "indexmap 2.10.0", @@ -2550,7 +2550,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.11.0" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "bytes", "headers", @@ -2572,7 +2572,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.10.1" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "js_int", "thiserror 2.0.12", @@ -2581,7 +2581,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.15.1" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "cfg-if", "proc-macro-crate", @@ -2596,7 +2596,7 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" version = "0.11.0" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "js_int", "ruma-common", @@ -2608,7 +2608,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.17.0" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "base64", "ed25519-dalek", @@ -2624,7 +2624,7 @@ dependencies = [ [[package]] name = "ruma-state-res" version = "0.13.0" -source = "git+https://github.com/ruma/ruma.git?rev=d84760a925d8e5830d668b031fec53ddf9101814#d84760a925d8e5830d668b031fec53ddf9101814" +source = "git+https://github.com/ruma/ruma.git?rev=e8b0876dda083433a7f9181d47d0aff5a5e05497#e8b0876dda083433a7f9181d47d0aff5a5e05497" dependencies = [ "js_int", "ruma-common", diff --git a/Cargo.toml b/Cargo.toml index 94296359..9f864aed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -145,7 +145,7 @@ xdg = "2.5.2" [dependencies.ruma] git = "https://github.com/ruma/ruma.git" -rev = "d84760a925d8e5830d668b031fec53ddf9101814" +rev = "e8b0876dda083433a7f9181d47d0aff5a5e05497" features = [ "compat-server-signing-key-version", "compat-empty-string-null", diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index 6fb9438a..9415e77c 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -1036,7 +1036,7 @@ async fn join_room_by_id_helper( } info!("Running send_join auth check"); - let authenticated = state_res::event_auth::auth_check( + state_res::event_auth::auth_check( &state_res::RoomVersion::new(&room_version_id).map_err(|_| { Error::UnsupportedRoomVersion(room_version_id.clone()) })?, @@ -1065,13 +1065,6 @@ async fn join_room_by_id_helper( Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed") })?; - if !authenticated { - return Err(Error::BadRequest( - ErrorKind::InvalidParam, - "Auth check failed", - )); - } - info!("Saving state from send_join"); let (statehash_before_join, new, removed) = services().rooms.state_compressor.save_state( diff --git a/src/service/rooms/event_handler.rs b/src/service/rooms/event_handler.rs index 1307e52d..e53e883d 100644 --- a/src/service/rooms/event_handler.rs +++ b/src/service/rooms/event_handler.rs @@ -501,19 +501,14 @@ impl Service { )); } - if !state_res::event_auth::auth_check( + state_res::event_auth::auth_check( &ruma_room_version, &incoming_pdu, |k, s| auth_events.get(&(k.to_string().into(), s.to_owned())), ) .map_err(|_e| { Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed") - })? { - return Err(Error::BadRequest( - ErrorKind::InvalidParam, - "Auth check failed", - )); - } + })?; debug!("Validation successful"); @@ -869,7 +864,7 @@ impl Service { debug!("Starting auth check"); // 11. Check the auth of the event passes based on the state of the // event - let check_result = state_res::event_auth::auth_check( + state_res::event_auth::auth_check( &ruma_room_version, &incoming_pdu, |k, s| { @@ -895,12 +890,6 @@ impl Service { .map_err(|_e| { Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed.") })?; - - if !check_result { - return Err(Error::bad_database( - "Event has failed auth check with state at the event.", - )); - } debug!("Auth check succeeded"); // Soft fail check before doing state res @@ -912,14 +901,12 @@ impl Service { &incoming_pdu.content, )?; - let auth_fail_against_current = !state_res::event_auth::auth_check( + let auth_fail_against_current = state_res::event_auth::auth_check( &ruma_room_version, &incoming_pdu, |k, s| auth_events.get(&(k.clone(), s.to_owned())), ) - .map_err(|_e| { - Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed.") - })?; + .is_err(); let cannot_redact = incoming_pdu.kind == TimelineEventType::RoomRedaction diff --git a/src/service/rooms/timeline.rs b/src/service/rooms/timeline.rs index 3635b082..7ea2e3dc 100644 --- a/src/service/rooms/timeline.rs +++ b/src/service/rooms/timeline.rs @@ -844,21 +844,13 @@ impl Service { signatures: None, }; - let auth_check = - state_res::auth_check(&ruma_room_version, &pdu, |k, s| { - auth_events.get(&(k.clone(), s.to_owned())) - }) - .map_err(|error| { - error!(%error, "Auth check failed"); - Error::BadDatabase("Auth check failed.") - })?; - - if !auth_check { - return Err(Error::BadRequest( - ErrorKind::forbidden(), - "Event is not authorized.", - )); - } + state_res::auth_check(&ruma_room_version, &pdu, |k, s| { + auth_events.get(&(k.clone(), s.to_owned())) + }) + .map_err(|error| { + error!(%error, "Auth check failed"); + Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed.") + })?; // Hash and sign let mut pdu_json = utils::to_canonical_object(&pdu)