Re-fetch object if attributedTo value doesn't match actor of Create activity
This commit is contained in:
parent
1860a48c4b
commit
485378d252
2 changed files with 11 additions and 1 deletions
|
@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Check mention and link counts when creating post.
|
||||
- Disable transaction monitor tasks if blockchain integration is disabled.
|
||||
- Allow multiple configurations in `blockchains` array.
|
||||
- Re-fetch object if `attributedTo` value doesn't match `actor` of `Create` activity.
|
||||
|
||||
## [1.20.0] - 2023-03-07
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ pub async fn handle_create(
|
|||
config: &Config,
|
||||
db_client: &mut impl DatabaseClient,
|
||||
activity: JsonValue,
|
||||
is_authenticated: bool,
|
||||
mut is_authenticated: bool,
|
||||
) -> HandlerResult {
|
||||
let object: Object = serde_json::from_value(activity["object"].to_owned())
|
||||
.map_err(|_| ValidationError("invalid object"))?;
|
||||
|
@ -691,6 +691,15 @@ pub async fn handle_create(
|
|||
return Ok(None);
|
||||
};
|
||||
|
||||
// Verify attribution
|
||||
let actor_id = activity["actor"].as_str()
|
||||
.ok_or(ValidationError("actor property is missing"))?;
|
||||
let author_id = get_object_attributed_to(&object)?;
|
||||
if actor_id != author_id {
|
||||
log::warn!("attributedTo value doesn't match actor");
|
||||
is_authenticated = false; // Object will be fetched
|
||||
};
|
||||
|
||||
let object_id = object.id.clone();
|
||||
let object_received = if is_authenticated {
|
||||
Some(object)
|
||||
|
|
Loading…
Reference in a new issue