Update ruma to latest, fix unstable origin feature in ruma
This commit is contained in:
parent
49f6ab503a
commit
96dd3b2880
13 changed files with 577 additions and 234 deletions
|
@ -1,7 +1,8 @@
|
|||
use crate::Error;
|
||||
use ruma::{
|
||||
api::{Outgoing, OutgoingRequest},
|
||||
api::{AuthScheme, OutgoingRequest},
|
||||
identifiers::{DeviceId, UserId},
|
||||
Outgoing,
|
||||
};
|
||||
use std::{convert::TryFrom, convert::TryInto, ops::Deref};
|
||||
|
||||
|
@ -61,28 +62,30 @@ where
|
|||
.await
|
||||
.expect("database was loaded");
|
||||
|
||||
let (sender_user, sender_device) = if T::METADATA.requires_authentication {
|
||||
// Get token from header or query value
|
||||
let token = match request
|
||||
.headers()
|
||||
.get_one("Authorization")
|
||||
.map(|s| s[7..].to_owned()) // Split off "Bearer "
|
||||
.or_else(|| request.get_query_value("access_token").and_then(|r| r.ok()))
|
||||
{
|
||||
// TODO: M_MISSING_TOKEN
|
||||
None => return Failure((Status::Unauthorized, ())),
|
||||
Some(token) => token,
|
||||
};
|
||||
let (sender_user, sender_device) =
|
||||
// TODO: Do we need to matches! anything else here? ServerSignatures
|
||||
if matches!(T::METADATA.authentication, AuthScheme::AccessToken | AuthScheme::QueryOnlyAccessToken) {
|
||||
// Get token from header or query value
|
||||
let token = match request
|
||||
.headers()
|
||||
.get_one("Authorization")
|
||||
.map(|s| s[7..].to_owned()) // Split off "Bearer "
|
||||
.or_else(|| request.get_query_value("access_token").and_then(|r| r.ok()))
|
||||
{
|
||||
// TODO: M_MISSING_TOKEN
|
||||
None => return Failure((Status::Unauthorized, ())),
|
||||
Some(token) => token,
|
||||
};
|
||||
|
||||
// Check if token is valid
|
||||
match db.users.find_from_token(&token).unwrap() {
|
||||
// TODO: M_UNKNOWN_TOKEN
|
||||
None => return Failure((Status::Unauthorized, ())),
|
||||
Some((user_id, device_id)) => (Some(user_id), Some(device_id.into())),
|
||||
}
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
// Check if token is valid
|
||||
match db.users.find_from_token(&token).unwrap() {
|
||||
// TODO: M_UNKNOWN_TOKEN
|
||||
None => return Failure((Status::Unauthorized, ())),
|
||||
Some((user_id, device_id)) => (Some(user_id), Some(device_id.into())),
|
||||
}
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
|
||||
let mut http_request = http::Request::builder()
|
||||
.uri(request.uri().to_string())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue