mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-25 06:31:10 +00:00
Add domain checks for federation
This commit is contained in:
parent
41a4d18949
commit
dd56a3f0d5
3 changed files with 12 additions and 6 deletions
|
@ -5,6 +5,7 @@ use crate::common::DbInstance;
|
||||||
|
|
||||||
use crate::common::DbArticle;
|
use crate::common::DbArticle;
|
||||||
use activitypub_federation::kinds::collection::CollectionType;
|
use activitypub_federation::kinds::collection::CollectionType;
|
||||||
|
use activitypub_federation::protocol::verification::verify_domains_match;
|
||||||
use activitypub_federation::{
|
use activitypub_federation::{
|
||||||
config::Data,
|
config::Data,
|
||||||
traits::{Collection, Object},
|
traits::{Collection, Object},
|
||||||
|
@ -55,10 +56,11 @@ impl Collection for DbArticleCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn verify(
|
async fn verify(
|
||||||
_apub: &Self::Kind,
|
json: &Self::Kind,
|
||||||
_expected_domain: &Url,
|
expected_domain: &Url,
|
||||||
_data: &Data<Self::DataType>,
|
_data: &Data<Self::DataType>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
|
verify_domains_match(&json.id, expected_domain)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ use crate::common::EditVersion;
|
||||||
use crate::common::{DbArticle, DbEdit};
|
use crate::common::{DbArticle, DbEdit};
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use activitypub_federation::fetch::object_id::ObjectId;
|
use activitypub_federation::fetch::object_id::ObjectId;
|
||||||
|
use activitypub_federation::protocol::verification::verify_domains_match;
|
||||||
use activitypub_federation::traits::Object;
|
use activitypub_federation::traits::Object;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -63,10 +64,11 @@ impl Object for DbEdit {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn verify(
|
async fn verify(
|
||||||
_json: &Self::Kind,
|
json: &Self::Kind,
|
||||||
_expected_domain: &Url,
|
expected_domain: &Url,
|
||||||
_data: &Data<Self::DataType>,
|
_data: &Data<Self::DataType>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
|
verify_domains_match(json.id.inner(), expected_domain)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ use crate::common::DbArticle;
|
||||||
use crate::common::DbEdit;
|
use crate::common::DbEdit;
|
||||||
use crate::common::DbInstance;
|
use crate::common::DbInstance;
|
||||||
use activitypub_federation::kinds::collection::OrderedCollectionType;
|
use activitypub_federation::kinds::collection::OrderedCollectionType;
|
||||||
|
use activitypub_federation::protocol::verification::verify_domains_match;
|
||||||
use activitypub_federation::{
|
use activitypub_federation::{
|
||||||
config::Data,
|
config::Data,
|
||||||
traits::{Collection, Object},
|
traits::{Collection, Object},
|
||||||
|
@ -59,10 +60,11 @@ impl Collection for DbEditCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn verify(
|
async fn verify(
|
||||||
_apub: &Self::Kind,
|
json: &Self::Kind,
|
||||||
_expected_domain: &Url,
|
expected_domain: &Url,
|
||||||
_data: &Data<Self::DataType>,
|
_data: &Data<Self::DataType>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
|
verify_domains_match(&json.id, expected_domain)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue