1 Commits

Author SHA1 Message Date
9412a9739a fix: allow www. apex equivalence in actor domain verification
Threads serves actors at threads.net but their id field uses www.threads.net.
Extract apex_domain() helper and fall back to apex comparison when the
strict verify_domains_match check fails.
2026-05-27 22:49:30 +02:00
3 changed files with 14 additions and 4 deletions

2
Cargo.lock generated
View File

@@ -1368,7 +1368,7 @@ dependencies = [
[[package]]
name = "k-ap"
version = "0.1.4"
version = "0.1.5"
dependencies = [
"activitypub_federation",
"anyhow",

View File

@@ -1,6 +1,6 @@
[package]
name = "k-ap"
version = "0.1.5"
version = "0.1.6"
edition = "2024"
description = "Generic ActivityPub protocol layer"
license = "MIT"

View File

@@ -193,6 +193,11 @@ pub async fn get_local_actor(
})
}
fn apex_domain(url: &Url) -> String {
let host = url.host_str().unwrap_or("");
host.strip_prefix("www.").unwrap_or(host).to_owned()
}
#[async_trait::async_trait]
impl Object for DbActor {
type DataType = FederationData;
@@ -319,8 +324,13 @@ impl Object for DbActor {
expected_domain: &Url,
_data: &Data<Self::DataType>,
) -> Result<(), Self::Error> {
verify_domains_match(json.id.inner(), expected_domain)?;
Ok(())
if verify_domains_match(json.id.inner(), expected_domain).is_ok() {
return Ok(());
}
if apex_domain(json.id.inner()) == apex_domain(expected_domain) {
return Ok(());
}
verify_domains_match(json.id.inner(), expected_domain).map_err(Error::from)
}
async fn from_json(json: Self::Kind, data: &Data<Self::DataType>) -> Result<Self, Self::Error> {