Skip to content

Commit

Permalink
wip: stub
Browse files Browse the repository at this point in the history
  • Loading branch information
junkurihara committed Apr 10, 2024
1 parent c33e064 commit f3754c3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 4 deletions.
74 changes: 71 additions & 3 deletions httpsig-hyper/src/hyper_http.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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
Expand Down Expand Up @@ -72,7 +72,8 @@ pub trait RequestMessageSignature {
fn extract_signatures(&self) -> Result<IndexMap<SignatureName, (HttpSignatureBase, HttpSignatureHeaders)>, Self::Error>;
}

impl<D> RequestMessageSignature for Request<D>
/* --------------------------------------- */
impl<D> MessageSignature for Request<D>
where
D: Send + Body + Sync,
{
Expand Down Expand Up @@ -227,6 +228,73 @@ where
}
}

/* --------------------------------------- */
impl<D> MessageSignature for Response<D>
where
D: Send + Body + Sync,
{
type Error = HyperSigError;

async fn set_message_signature<T>(
&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<T>(
&mut self,
params_key_name: &[(&HttpSignatureParams, &T, Option<&str>)],
) -> Result<(), Self::Error>
where
Self: Sized,
T: SigningKey + Sync,
{
todo!()
}

async fn verify_message_signature<T>(&self, verifying_key: &T, key_id: Option<&str>) -> Result<SignatureName, Self::Error>
where
Self: Sized,
T: VerifyingKey + Sync,
{
todo!()
}

async fn verify_message_signatures<T>(
&self,
key_and_id: &[(&T, Option<&str>)],
) -> Result<Vec<Result<SignatureName, Self::Error>>, Self::Error>
where
Self: Sized,
T: VerifyingKey + Sync,
{
todo!()
}

fn has_message_signature(&self) -> bool {
todo!()
}

fn get_key_ids(&self) -> Result<IndexMap<SignatureName, KeyId>, Self::Error> {
todo!()
}

fn get_signature_params(&self) -> Result<IndexMap<SignatureName, HttpSignatureParams>, Self::Error> {
todo!()
}

fn extract_signatures(&self) -> Result<IndexMap<SignatureName, (HttpSignatureBase, HttpSignatureHeaders)>, Self::Error> {
todo!()
}
}

/* --------------------------------------- */

/// Extract signature and signature-input with signature-name indication from http request
Expand Down
2 changes: 1 addition & 1 deletion httpsig-hyper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit f3754c3

Please sign in to comment.