Enforce sig is from correct actor
This commit is contained in:
@@ -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,
|
||||
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user