Skip to content
Snippets Groups Projects
Commit f263630a authored by 🥺's avatar 🥺 :transgender_flag: Committed by 🥺
Browse files

fix: use `path_and_query()` for `"uri"` in request_map for signatures


resolves X-Matrix signatures being invalid in some edge-cases,
and fixes Complement/Sytest federation tests

Signed-off-by: default avatarstrawberry <strawberry@puppygock.gay>
parent 81f54926
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
BoxError, RequestExt, RequestPartsExt, BoxError, RequestExt, RequestPartsExt,
}; };
use bytes::{Buf, BufMut, Bytes, BytesMut}; use bytes::{Buf, BufMut, Bytes, BytesMut};
use http::{Request, StatusCode}; use http::{uri::PathAndQuery, Request, StatusCode};
use ruma::{ use ruma::{
api::{client::error::ErrorKind, AuthScheme, IncomingRequest, OutgoingResponse}, api::{client::error::ErrorKind, AuthScheme, IncomingRequest, OutgoingResponse},
CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId, UserId, CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId, UserId,
...@@ -203,9 +203,17 @@ async fn from_request(req: Request<B>, _state: &S) -> Result<Self, Self::Rejecti ...@@ -203,9 +203,17 @@ async fn from_request(req: Request<B>, _state: &S) -> Result<Self, Self::Rejecti
} }
} }
let signature_uri = CanonicalJsonValue::String(
parts
.uri
.path_and_query()
.unwrap_or(&PathAndQuery::from_static("/"))
.to_string(),
);
let mut request_map = BTreeMap::from_iter([ let mut request_map = BTreeMap::from_iter([
("method".to_owned(), CanonicalJsonValue::String(parts.method.to_string())), ("method".to_owned(), CanonicalJsonValue::String(parts.method.to_string())),
("uri".to_owned(), CanonicalJsonValue::String(parts.uri.to_string())), ("uri".to_owned(), signature_uri),
( (
"origin".to_owned(), "origin".to_owned(),
CanonicalJsonValue::String(x_matrix.origin.as_str().to_owned()), CanonicalJsonValue::String(x_matrix.origin.as_str().to_owned()),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment