Skip to content

Commit

Permalink
add api
Browse files Browse the repository at this point in the history
  • Loading branch information
junkurihara committed Mar 5, 2024
1 parent 727ade0 commit 93a8aa0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"

[workspace.package]
edition = "2021"
version = "0.0.10"
version = "0.0.11"
authors = ["Jun Kurihara"]
homepage = "https://github.com/junkurihara/httpsig-rs"
repository = "https://github.com/junkurihara/httpsig-rs"
Expand Down
2 changes: 1 addition & 1 deletion httpsig-hyper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
httpsig = { path = "../httpsig", version = "0.0.10" }
httpsig = { path = "../httpsig", version = "0.0.11" }

thiserror = { version = "1.0.57" }
tracing = { version = "0.1.40" }
Expand Down
13 changes: 13 additions & 0 deletions httpsig-hyper/src/hyper_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub trait RequestMessageSignature {
/// Extract all key ids for signature bases contained in the request headers
fn get_key_ids(&self) -> Result<Vec<String>, Self::Error>;

/// Extract all signature params used to generate signature bases contained in the request headers
fn get_signature_params(&self) -> Result<Vec<HttpSignatureParams>, Self::Error>;

/// Extract all signature bases contained in the request headers
fn extract_signatures(&self) -> Result<Vec<(HttpSignatureBase, HttpSignatureHeaders)>, Self::Error>;
}
Expand Down Expand Up @@ -134,6 +137,16 @@ where
Ok(res)
}

/// Extract all signature params used to generate signature bases contained in the request headers
fn get_signature_params(&self) -> Result<Vec<HttpSignatureParams>, Self::Error> {
let signature_headers_map = extract_signature_headers_with_name(self)?;
let res = signature_headers_map
.iter()
.map(|(_, headers)| headers.signature_params().clone())
.collect::<Vec<_>>();
Ok(res)
}

/// Extract all signature bases contained in the request headers
fn extract_signatures(&self) -> Result<Vec<(HttpSignatureBase, HttpSignatureHeaders)>, Self::Error> {
let signature_headers_map = extract_signature_headers_with_name(self)?;
Expand Down

0 comments on commit 93a8aa0

Please sign in to comment.