|
|
|
@ -34,7 +34,8 @@ pub struct Ruma<T: Outgoing> { |
|
|
|
pub body: T::Incoming, |
|
|
|
pub body: T::Incoming, |
|
|
|
pub sender_user: Option<UserId>, |
|
|
|
pub sender_user: Option<UserId>, |
|
|
|
pub sender_device: Option<Box<DeviceId>>, |
|
|
|
pub sender_device: Option<Box<DeviceId>>, |
|
|
|
pub json_body: Option<Box<serde_json::value::RawValue>>, // This is None when body is not a valid string
|
|
|
|
// This is None when body is not a valid string
|
|
|
|
|
|
|
|
pub json_body: Option<Box<serde_json::value::RawValue>>, |
|
|
|
pub from_appservice: bool, |
|
|
|
pub from_appservice: bool, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -124,22 +125,24 @@ where |
|
|
|
} |
|
|
|
} |
|
|
|
AuthScheme::ServerSignatures => { |
|
|
|
AuthScheme::ServerSignatures => { |
|
|
|
// Get origin from header
|
|
|
|
// Get origin from header
|
|
|
|
let x_matrix = match request |
|
|
|
let x_matrix = match request.headers().get_one("Authorization").map(|s| { |
|
|
|
.headers() |
|
|
|
// Split off "X-Matrix " and parse the rest
|
|
|
|
.get_one("Authorization") |
|
|
|
s[9..] |
|
|
|
.map(|s| { |
|
|
|
.split_terminator(',') |
|
|
|
s[9..] |
|
|
|
.map(|field| { |
|
|
|
.split_terminator(',').map(|field| {let mut splits = field.splitn(2, '='); (splits.next(), splits.next().map(|s| s.trim_matches('"')))}).collect::<BTreeMap<_, _>>() |
|
|
|
let mut splits = field.splitn(2, '='); |
|
|
|
}) // Split off "X-Matrix " and parse the rest
|
|
|
|
(splits.next(), splits.next().map(|s| s.trim_matches('"'))) |
|
|
|
{ |
|
|
|
}) |
|
|
|
Some(t) => t, |
|
|
|
.collect::<BTreeMap<_, _>>() |
|
|
|
None => { |
|
|
|
}) { |
|
|
|
warn!("No Authorization header"); |
|
|
|
Some(t) => t, |
|
|
|
|
|
|
|
None => { |
|
|
|
// Forbidden
|
|
|
|
warn!("No Authorization header"); |
|
|
|
return Failure((Status::raw(580), ())); |
|
|
|
|
|
|
|
} |
|
|
|
// Forbidden
|
|
|
|
}; |
|
|
|
return Failure((Status::raw(580), ())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let origin_str = match x_matrix.get(&Some("origin")) { |
|
|
|
let origin_str = match x_matrix.get(&Some("origin")) { |
|
|
|
Some(Some(o)) => *o, |
|
|
|
Some(Some(o)) => *o, |
|
|
|
|