Enforce sig is from correct actor

This commit is contained in:
asonix
2020-03-17 14:52:33 -05:00
parent 86a760a8e4
commit 9642e357e5
4 changed files with 17 additions and 3 deletions
+3
View File
@@ -30,6 +30,9 @@ pub enum MyError {
#[error("Couldn't decode base64")]
Base64(#[from] base64::DecodeError),
#[error("Actor tried to submit another actor's payload")]
BadActor,
#[error("Invalid algorithm provided to verifier")]
Algorithm,
+11
View File
@@ -15,6 +15,7 @@ use activitystreams::{
use actix::Addr;
use actix_web::{client::Client, web, HttpResponse};
use futures::join;
use http_signature_normalization_actix::middleware::SignatureVerified;
use log::error;
pub async fn inbox(
@@ -22,9 +23,19 @@ pub async fn inbox(
state: web::Data<State>,
client: web::Data<Client>,
input: web::Json<AcceptedObjects>,
verified: SignatureVerified,
) -> Result<HttpResponse, MyError> {
let input = input.into_inner();
if input.actor.as_str() != verified.key_id() {
error!(
"Request payload and requestor disagree on actor, {} != {}",
input.actor,
verified.key_id()
);
return Err(MyError::BadActor);
}
let actor = fetch_actor(
state.clone().into_inner(),
client.clone().into_inner(),