mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-22 09:31:07 +00:00
Add host to signatures
This commit is contained in:
parent
1d0a1d7cfd
commit
b6e25df717
4 changed files with 260 additions and 235 deletions
458
Cargo.lock
generated
458
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -33,7 +33,7 @@ env_logger = "0.7.1"
|
||||||
futures = "0.3.4"
|
futures = "0.3.4"
|
||||||
http-signature-normalization-actix = { version = "0.4.0-alpha.1", default-features = false, features = ["sha-2"] }
|
http-signature-normalization-actix = { version = "0.4.0-alpha.1", default-features = false, features = ["sha-2"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
lru = "0.5.1"
|
lru = "0.6.0"
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
num_cpus = "1.12"
|
num_cpus = "1.12"
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = "0.4.0"
|
||||||
|
@ -54,7 +54,7 @@ uuid = { version = "0.8", features = ["v4", "serde"] }
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
ructe = { version = "0.11.0", features = ["sass", "mime03"] }
|
ructe = { version = "0.12.0", features = ["sass", "mime03"] }
|
||||||
|
|
||||||
[profile.dev.package.rsa]
|
[profile.dev.package.rsa]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
|
@ -96,6 +96,9 @@ pub enum MyError {
|
||||||
#[error("Response from {0} has invalid status code, {1}")]
|
#[error("Response from {0} has invalid status code, {1}")]
|
||||||
Status(String, StatusCode),
|
Status(String, StatusCode),
|
||||||
|
|
||||||
|
#[error("Uri {0} is missing host")]
|
||||||
|
Host(String),
|
||||||
|
|
||||||
#[error("Expected an Object, found something else")]
|
#[error("Expected an Object, found something else")]
|
||||||
ObjectFormat,
|
ObjectFormat,
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,14 @@ impl Requests {
|
||||||
let signer = self.signer();
|
let signer = self.signer();
|
||||||
|
|
||||||
let client: Client = self.client.borrow().clone();
|
let client: Client = self.client.borrow().clone();
|
||||||
let res = client
|
let req = client.get(url);
|
||||||
.get(url)
|
let host = req
|
||||||
|
.get_uri()
|
||||||
|
.host()
|
||||||
|
.ok_or(MyError::Host(url.to_string()))?
|
||||||
|
.to_string();
|
||||||
|
let res = req
|
||||||
|
.header("Host", host)
|
||||||
.header("Accept", accept)
|
.header("Accept", accept)
|
||||||
.set(Date(SystemTime::now().into()))
|
.set(Date(SystemTime::now().into()))
|
||||||
.signature(
|
.signature(
|
||||||
|
@ -123,8 +129,14 @@ impl Requests {
|
||||||
let signer = self.signer();
|
let signer = self.signer();
|
||||||
|
|
||||||
let client: Client = self.client.borrow().clone();
|
let client: Client = self.client.borrow().clone();
|
||||||
let res = client
|
let req = client.get(url);
|
||||||
.get(url)
|
let host = req
|
||||||
|
.get_uri()
|
||||||
|
.host()
|
||||||
|
.ok_or(MyError::Host(url.to_string()))?
|
||||||
|
.to_string();
|
||||||
|
let res = req
|
||||||
|
.header("Host", host)
|
||||||
.header("Accept", "*/*")
|
.header("Accept", "*/*")
|
||||||
.set(Date(SystemTime::now().into()))
|
.set(Date(SystemTime::now().into()))
|
||||||
.signature(
|
.signature(
|
||||||
|
@ -184,8 +196,14 @@ impl Requests {
|
||||||
let item_string = serde_json::to_string(item)?;
|
let item_string = serde_json::to_string(item)?;
|
||||||
|
|
||||||
let client: Client = self.client.borrow().clone();
|
let client: Client = self.client.borrow().clone();
|
||||||
let res = client
|
let req = client.post(inbox.as_str());
|
||||||
.post(inbox.as_str())
|
let host = req
|
||||||
|
.get_uri()
|
||||||
|
.host()
|
||||||
|
.ok_or(MyError::Host(inbox.to_string()))?
|
||||||
|
.to_string();
|
||||||
|
let res = req
|
||||||
|
.header("Host", host)
|
||||||
.header("Accept", "application/activity+json")
|
.header("Accept", "application/activity+json")
|
||||||
.header("Content-Type", "application/activity+json")
|
.header("Content-Type", "application/activity+json")
|
||||||
.set(Date(SystemTime::now().into()))
|
.set(Date(SystemTime::now().into()))
|
||||||
|
|
Loading…
Reference in a new issue