From f3754c311e210bbf65f2e2c6cfe92d5b57e1c94a Mon Sep 17 00:00:00 2001 From: Jun Kurihara Date: Wed, 10 Apr 2024 17:22:58 +0900 Subject: [PATCH] wip: stub --- httpsig-hyper/src/hyper_http.rs | 74 +++++++++++++++++++++++++++++++-- httpsig-hyper/src/lib.rs | 2 +- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/httpsig-hyper/src/hyper_http.rs b/httpsig-hyper/src/hyper_http.rs index 282d051..b87d00e 100644 --- a/httpsig-hyper/src/hyper_http.rs +++ b/httpsig-hyper/src/hyper_http.rs @@ -1,5 +1,5 @@ use crate::error::{HyperSigError, HyperSigResult}; -use http::Request; +use http::{Request, Response}; use http_body::Body; use httpsig::prelude::{ message_component::{ @@ -17,7 +17,7 @@ type KeyId = String; /* --------------------------------------- */ /// A trait to set the http message signature from given http signature params -pub trait RequestMessageSignature { +pub trait MessageSignature { type Error; /// Set the http message signature from given http signature params and signing key @@ -72,7 +72,8 @@ pub trait RequestMessageSignature { fn extract_signatures(&self) -> Result, Self::Error>; } -impl RequestMessageSignature for Request +/* --------------------------------------- */ +impl MessageSignature for Request where D: Send + Body + Sync, { @@ -227,6 +228,73 @@ where } } +/* --------------------------------------- */ +impl MessageSignature for Response +where + D: Send + Body + Sync, +{ + type Error = HyperSigError; + + async fn set_message_signature( + &mut self, + signature_params: &HttpSignatureParams, + signing_key: &T, + signature_name: Option<&str>, + ) -> Result<(), Self::Error> + where + Self: Sized, + T: SigningKey + Sync, + { + todo!() + } + + async fn set_message_signatures( + &mut self, + params_key_name: &[(&HttpSignatureParams, &T, Option<&str>)], + ) -> Result<(), Self::Error> + where + Self: Sized, + T: SigningKey + Sync, + { + todo!() + } + + async fn verify_message_signature(&self, verifying_key: &T, key_id: Option<&str>) -> Result + where + Self: Sized, + T: VerifyingKey + Sync, + { + todo!() + } + + async fn verify_message_signatures( + &self, + key_and_id: &[(&T, Option<&str>)], + ) -> Result>, Self::Error> + where + Self: Sized, + T: VerifyingKey + Sync, + { + todo!() + } + + fn has_message_signature(&self) -> bool { + todo!() + } + + fn get_key_ids(&self) -> Result, Self::Error> { + todo!() + } + + fn get_signature_params(&self) -> Result, Self::Error> { + todo!() + } + + fn extract_signatures(&self) -> Result, Self::Error> { + todo!() + } +} + /* --------------------------------------- */ /// Extract signature and signature-input with signature-name indication from http request diff --git a/httpsig-hyper/src/lib.rs b/httpsig-hyper/src/lib.rs index 95e9dd0..38d04d4 100644 --- a/httpsig-hyper/src/lib.rs +++ b/httpsig-hyper/src/lib.rs @@ -36,7 +36,7 @@ impl std::str::FromStr for ContentDigestType { pub use error::{HyperDigestError, HyperDigestResult, HyperSigError, HyperSigResult}; pub use httpsig::prelude; pub use hyper_content_digest::{ContentDigest, RequestContentDigest, ResponseContentDigest}; -pub use hyper_http::RequestMessageSignature; +pub use hyper_http::MessageSignature; /* ----------------------------------------------------------------- */ #[cfg(test)]