diff --git a/src/routes/activitypub/inbox.rs b/src/routes/activitypub/inbox.rs index d2fe203..68b2c80 100644 --- a/src/routes/activitypub/inbox.rs +++ b/src/routes/activitypub/inbox.rs @@ -1,4 +1,4 @@ -use apb::{server::Inbox, target::Addressed, Activity, ActivityType, Base, BaseType, ObjectType}; +use apb::{server::Inbox, ActivityType, Base, BaseType, ObjectType}; use axum::{extract::{Query, State}, http::StatusCode, Json}; use sea_orm::{Order, QueryFilter, QueryOrder, QuerySelect}; diff --git a/src/server/auth.rs b/src/server/auth.rs index b29ac9b..621122a 100644 --- a/src/server/auth.rs +++ b/src/server/auth.rs @@ -68,10 +68,7 @@ where .get("Signature") .map(|v| v.to_str().unwrap_or("")) { - let mut signature_cfg = Config::new() - .dont_use_created_field() - .require_header("host") - .require_header("date"); + let mut signature_cfg = Config::new().mastodon_compat(); let mut headers : BTreeMap = [ ("Signature".to_string(), sig.to_string()), ("Host".to_string(), header_get(&parts.headers, "Host")), diff --git a/src/server/fetcher.rs b/src/server/fetcher.rs index fb57ed6..ec28b33 100644 --- a/src/server/fetcher.rs +++ b/src/server/fetcher.rs @@ -38,11 +38,12 @@ impl Fetcher { ("Date".to_string(), date.clone()), ].into(); - let mut client = - reqwest::Client::new() - .request(method, url) - .header("Host", host) - .header("Date", date); + let mut client = reqwest::Client::new() + .request(method, url) + .header(CONTENT_TYPE, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") + .header(USER_AGENT, format!("upub+{VERSION} ({domain})")) + .header("Host", host) + .header("Date", date); let mut signature_cfg = Config::new(); @@ -56,13 +57,10 @@ impl Fetcher { } let signature_header = signature_cfg - .dont_use_created_field() - .require_header("host") - .require_header("date") + .mastodon_compat() .begin_sign("POST", &path, headers) .unwrap() .sign(format!("{from}#main-key"), |to_sign| { - tracing::info!("signing '{to_sign}'"); let mut signer = Signer::new(MessageDigest::sha256(), key)?; signer.update(to_sign.as_bytes())?; let signature = base64::prelude::BASE64_URL_SAFE.encode(signer.sign_to_vec()?); @@ -73,8 +71,6 @@ impl Fetcher { client .header("Signature", signature_header) - .header(CONTENT_TYPE, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") - .header(USER_AGENT, format!("upub+{VERSION} ({domain})")) // TODO put instance admin email .send() .await? .error_for_status()?