fix: add destination field authorization handler (not my commit)
Signed-off-by: girlbossceo <june@girlboss.ceo>
This commit is contained in:
parent
ebd2ec45b1
commit
fda30f5602
1 changed files with 17 additions and 3 deletions
|
@ -178,6 +178,18 @@ where
|
||||||
CanonicalJsonValue::Object(origin_signatures),
|
CanonicalJsonValue::Object(origin_signatures),
|
||||||
)]);
|
)]);
|
||||||
|
|
||||||
|
let server_destination =
|
||||||
|
services().globals.server_name().as_str().to_owned();
|
||||||
|
|
||||||
|
if let Some(destination) = x_matrix.destination.as_ref() {
|
||||||
|
if destination != &server_destination {
|
||||||
|
return Err(Error::BadRequest(
|
||||||
|
ErrorKind::Forbidden,
|
||||||
|
"Invalid authorization.",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut request_map = BTreeMap::from_iter([
|
let mut request_map = BTreeMap::from_iter([
|
||||||
(
|
(
|
||||||
"method".to_owned(),
|
"method".to_owned(),
|
||||||
|
@ -193,9 +205,7 @@ where
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"destination".to_owned(),
|
"destination".to_owned(),
|
||||||
CanonicalJsonValue::String(
|
CanonicalJsonValue::String(server_destination),
|
||||||
services().globals.server_name().as_str().to_owned(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"signatures".to_owned(),
|
"signatures".to_owned(),
|
||||||
|
@ -310,6 +320,7 @@ where
|
||||||
|
|
||||||
struct XMatrix {
|
struct XMatrix {
|
||||||
origin: OwnedServerName,
|
origin: OwnedServerName,
|
||||||
|
destination: Option<String>,
|
||||||
key: String, // KeyName?
|
key: String, // KeyName?
|
||||||
sig: String,
|
sig: String,
|
||||||
}
|
}
|
||||||
|
@ -328,6 +339,7 @@ impl Credentials for XMatrix {
|
||||||
.trim_start();
|
.trim_start();
|
||||||
|
|
||||||
let mut origin = None;
|
let mut origin = None;
|
||||||
|
let mut destination = None;
|
||||||
let mut key = None;
|
let mut key = None;
|
||||||
let mut sig = None;
|
let mut sig = None;
|
||||||
|
|
||||||
|
@ -346,6 +358,7 @@ impl Credentials for XMatrix {
|
||||||
"origin" => origin = Some(value.try_into().ok()?),
|
"origin" => origin = Some(value.try_into().ok()?),
|
||||||
"key" => key = Some(value.to_owned()),
|
"key" => key = Some(value.to_owned()),
|
||||||
"sig" => sig = Some(value.to_owned()),
|
"sig" => sig = Some(value.to_owned()),
|
||||||
|
"destination" => destination = Some(value.to_owned()),
|
||||||
_ => debug!(
|
_ => debug!(
|
||||||
"Unexpected field `{}` in X-Matrix Authorization header",
|
"Unexpected field `{}` in X-Matrix Authorization header",
|
||||||
name
|
name
|
||||||
|
@ -357,6 +370,7 @@ impl Credentials for XMatrix {
|
||||||
origin: origin?,
|
origin: origin?,
|
||||||
key: key?,
|
key: key?,
|
||||||
sig: sig?,
|
sig: sig?,
|
||||||
|
destination,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue