1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-25 02:11:10 +00:00

Add domain checks for federation

This commit is contained in:
Felix Ableitner 2024-02-27 16:21:30 +01:00
parent 41a4d18949
commit dd56a3f0d5
3 changed files with 12 additions and 6 deletions

View file

@ -5,6 +5,7 @@ use crate::common::DbInstance;
use crate::common::DbArticle;
use activitypub_federation::kinds::collection::CollectionType;
use activitypub_federation::protocol::verification::verify_domains_match;
use activitypub_federation::{
config::Data,
traits::{Collection, Object},
@ -55,10 +56,11 @@ impl Collection for DbArticleCollection {
}
async fn verify(
_apub: &Self::Kind,
_expected_domain: &Url,
json: &Self::Kind,
expected_domain: &Url,
_data: &Data<Self::DataType>,
) -> Result<(), Self::Error> {
verify_domains_match(&json.id, expected_domain)?;
Ok(())
}

View file

@ -6,6 +6,7 @@ use crate::common::EditVersion;
use crate::common::{DbArticle, DbEdit};
use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId;
use activitypub_federation::protocol::verification::verify_domains_match;
use activitypub_federation::traits::Object;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
@ -63,10 +64,11 @@ impl Object for DbEdit {
}
async fn verify(
_json: &Self::Kind,
_expected_domain: &Url,
json: &Self::Kind,
expected_domain: &Url,
_data: &Data<Self::DataType>,
) -> Result<(), Self::Error> {
verify_domains_match(json.id.inner(), expected_domain)?;
Ok(())
}

View file

@ -6,6 +6,7 @@ use crate::common::DbArticle;
use crate::common::DbEdit;
use crate::common::DbInstance;
use activitypub_federation::kinds::collection::OrderedCollectionType;
use activitypub_federation::protocol::verification::verify_domains_match;
use activitypub_federation::{
config::Data,
traits::{Collection, Object},
@ -59,10 +60,11 @@ impl Collection for DbEditCollection {
}
async fn verify(
_apub: &Self::Kind,
_expected_domain: &Url,
json: &Self::Kind,
expected_domain: &Url,
_data: &Data<Self::DataType>,
) -> Result<(), Self::Error> {
verify_domains_match(&json.id, expected_domain)?;
Ok(())
}