//! Utilities for using this library with actix-web framework mod http_compat; pub mod inbox; #[doc(hidden)] pub mod middleware; pub mod response; use crate::{ config::Data, error::Error, http_signatures::{self, verify_body_hash}, traits::{Actor, Object}, }; use actix_web::{web::Bytes, HttpRequest}; use serde::Deserialize; /// Checks whether the request is signed by an actor of type A, and returns /// the actor in question if a valid signature is found. pub async fn signing_actor( request: &HttpRequest, body: Option, data: &Data<::DataType>, ) -> Result::Error> where A: Object + Actor, ::Error: From, for<'de2> ::Kind: Deserialize<'de2>, { let digest_header = request .headers() .get("Digest") .map(http_compat::header_value); verify_body_hash(digest_header.as_ref(), &body.unwrap_or_default())?; let headers = http_compat::header_map(request.headers()); let method = http_compat::method(request.method()); let uri = http_compat::uri(request.uri()); http_signatures::signing_actor(&headers, &method, &uri, data).await }