From 6394b1812c1bf7f0dbd0a8238e6b95d934d57337 Mon Sep 17 00:00:00 2001 From: strawberry Date: Tue, 23 Apr 2024 19:37:11 -0400 Subject: [PATCH] use 403 for auth check fails everywhere else Signed-off-by: strawberry --- src/service/rooms/event_handler/mod.rs | 10 +++++----- src/service/rooms/timeline/mod.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/service/rooms/event_handler/mod.rs b/src/service/rooms/event_handler/mod.rs index 47b9295f..2f960bb1 100644 --- a/src/service/rooms/event_handler/mod.rs +++ b/src/service/rooms/event_handler/mod.rs @@ -406,9 +406,9 @@ impl Service { None::, // TODO: third party invite |k, s| auth_events.get(&(k.to_string().into(), s.to_owned())), ) - .map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed"))? + .map_err(|_e| Error::BadRequest(ErrorKind::forbidden(), "Auth check failed"))? { - return Err(Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed")); + return Err(Error::BadRequest(ErrorKind::forbidden(), "Auth check failed")); } trace!("Validation successful."); @@ -491,11 +491,11 @@ impl Service { .and_then(|event_id| services().rooms.timeline.get_pdu(event_id).ok().flatten()) }, ) - .map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed."))?; + .map_err(|_e| Error::BadRequest(ErrorKind::forbidden(), "Auth check failed."))?; if !check_result { return Err(Error::BadRequest( - ErrorKind::InvalidParam, + ErrorKind::forbidden(), "Event has failed auth check with state at the event.", )); } @@ -514,7 +514,7 @@ impl Service { let soft_fail = !state_res::event_auth::auth_check(&room_version, &incoming_pdu, None::, |k, s| { auth_events.get(&(k.clone(), s.to_owned())) }) - .map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed."))?; + .map_err(|_e| Error::BadRequest(ErrorKind::forbidden(), "Auth check failed."))?; // 13. Use state resolution to find new room state diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index 88c43a5d..126e51c5 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -737,7 +737,7 @@ impl Service { ) .map_err(|e| { error!("Auth check failed: {:?}", e); - Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed.") + Error::BadRequest(ErrorKind::forbidden(), "Auth check failed.") })?; if !auth_check {