mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-22 01:11:00 +00:00
Only mark required header as in-use if it's included in the signing string
This commit is contained in:
parent
597a61fb4b
commit
1997d54b36
2 changed files with 12 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "http-signature-normalization"
|
||||
description = "An HTTP Signatures library that leaves the signing to you"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
authors = ["asonix <asonix@asonix.dog>"]
|
||||
license-file = "LICENSE"
|
||||
readme = "README.md"
|
||||
|
|
20
src/lib.rs
20
src/lib.rs
|
@ -228,14 +228,6 @@ fn build_signing_string(
|
|||
btm: &mut BTreeMap<String, String>,
|
||||
mut required_headers: HashSet<String>,
|
||||
) -> Result<String, RequiredError> {
|
||||
for key in btm.keys() {
|
||||
required_headers.remove(key);
|
||||
}
|
||||
|
||||
if !required_headers.is_empty() {
|
||||
return Err(RequiredError(required_headers));
|
||||
}
|
||||
|
||||
let request_target = format!("{} {}", method.to_string().to_lowercase(), path_and_query);
|
||||
|
||||
btm.insert(REQUEST_TARGET.to_owned(), request_target.clone());
|
||||
|
@ -248,10 +240,20 @@ fn build_signing_string(
|
|||
|
||||
let signing_string = sig_headers
|
||||
.iter()
|
||||
.filter_map(|h| btm.remove(h).map(|v| format!("{}: {}", h, v)))
|
||||
.filter_map(|h| {
|
||||
let opt = btm.remove(h).map(|v| format!("{}: {}", h, v));
|
||||
if opt.is_some() {
|
||||
required_headers.remove(h);
|
||||
}
|
||||
opt
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
|
||||
if !required_headers.is_empty() {
|
||||
return Err(RequiredError(required_headers));
|
||||
}
|
||||
|
||||
Ok(signing_string)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue