Add host to signatures

This commit is contained in:
asonix
2020-09-07 13:34:29 -05:00
parent 1d0a1d7cfd
commit b6e25df717
4 changed files with 260 additions and 235 deletions
+3
View File
@@ -96,6 +96,9 @@ pub enum MyError {
#[error("Response from {0} has invalid status code, {1}")]
Status(String, StatusCode),
#[error("Uri {0} is missing host")]
Host(String),
#[error("Expected an Object, found something else")]
ObjectFormat,
+24 -6
View File
@@ -77,8 +77,14 @@ impl Requests {
let signer = self.signer();
let client: Client = self.client.borrow().clone();
let res = client
.get(url)
let req = client.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)
.set(Date(SystemTime::now().into()))
.signature(
@@ -123,8 +129,14 @@ impl Requests {
let signer = self.signer();
let client: Client = self.client.borrow().clone();
let res = client
.get(url)
let req = client.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", "*/*")
.set(Date(SystemTime::now().into()))
.signature(
@@ -184,8 +196,14 @@ impl Requests {
let item_string = serde_json::to_string(item)?;
let client: Client = self.client.borrow().clone();
let res = client
.post(inbox.as_str())
let req = client.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("Content-Type", "application/activity+json")
.set(Date(SystemTime::now().into()))