mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-22 01:11:00 +00:00
Clippy
This commit is contained in:
parent
1997d54b36
commit
a0974299c5
2 changed files with 16 additions and 17 deletions
27
src/lib.rs
27
src/lib.rs
|
@ -53,17 +53,17 @@ use self::{
|
|||
verify::{ParseSignatureError, ParsedHeader, Unverified, ValidateError},
|
||||
};
|
||||
|
||||
const REQUEST_TARGET: &'static str = "(request-target)";
|
||||
const CREATED: &'static str = "(created)";
|
||||
const EXPIRES: &'static str = "(expires)";
|
||||
const REQUEST_TARGET: &str = "(request-target)";
|
||||
const CREATED: &str = "(created)";
|
||||
const EXPIRES: &str = "(expires)";
|
||||
|
||||
const KEY_ID_FIELD: &'static str = "keyId";
|
||||
const ALGORITHM_FIELD: &'static str = "algorithm";
|
||||
const ALGORITHM_VALUE: &'static str = "hs2019";
|
||||
const CREATED_FIELD: &'static str = "created";
|
||||
const EXPIRES_FIELD: &'static str = "expires";
|
||||
const HEADERS_FIELD: &'static str = "headers";
|
||||
const SIGNATURE_FIELD: &'static str = "signature";
|
||||
const KEY_ID_FIELD: &str = "keyId";
|
||||
const ALGORITHM_FIELD: &str = "algorithm";
|
||||
const ALGORITHM_VALUE: &str = "hs2019";
|
||||
const CREATED_FIELD: &str = "created";
|
||||
const EXPIRES_FIELD: &str = "expires";
|
||||
const HEADERS_FIELD: &str = "headers";
|
||||
const SIGNATURE_FIELD: &str = "signature";
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
/// Configuration for signing and verifying signatures
|
||||
|
@ -124,8 +124,7 @@ impl Config {
|
|||
|
||||
/// Mark a header as required
|
||||
pub fn require_header(mut self, header: &str) -> Self {
|
||||
self.required_headers
|
||||
.insert(header.to_lowercase().to_owned());
|
||||
self.required_headers.insert(header.to_lowercase());
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -181,7 +180,7 @@ impl Config {
|
|||
) -> Result<Unverified, PrepareVerifyError> {
|
||||
let mut headers: BTreeMap<String, String> = headers
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k.to_lowercase().to_owned(), v))
|
||||
.map(|(k, v)| (k.to_lowercase(), v))
|
||||
.collect();
|
||||
|
||||
let header = headers
|
||||
|
@ -230,7 +229,7 @@ fn build_signing_string(
|
|||
) -> Result<String, RequiredError> {
|
||||
let request_target = format!("{} {}", method.to_string().to_lowercase(), path_and_query);
|
||||
|
||||
btm.insert(REQUEST_TARGET.to_owned(), request_target.clone());
|
||||
btm.insert(REQUEST_TARGET.to_owned(), request_target);
|
||||
if let Some(created) = created {
|
||||
btm.insert(CREATED.to_owned(), created.timestamp().to_string());
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ impl FromStr for ParsedHeader {
|
|||
let mut hm: HashMap<String, String> = s
|
||||
.split(',')
|
||||
.filter_map(|part| {
|
||||
let mut i = part.splitn(2, "=");
|
||||
let mut i = part.splitn(2, '=');
|
||||
|
||||
if let Some(key) = i.next() {
|
||||
if let Some(value) = i.next() {
|
||||
|
@ -271,7 +271,7 @@ impl FromStr for ParsedHeader {
|
|||
.remove(HEADERS_FIELD)
|
||||
.map(|h| h.split_whitespace().map(|s| s.to_owned()).collect())
|
||||
.unwrap_or_else(|| vec![CREATED.to_owned()]),
|
||||
algorithm: hm.remove(ALGORITHM_FIELD).map(|s| Algorithm::from(s)),
|
||||
algorithm: hm.remove(ALGORITHM_FIELD).map(Algorithm::from),
|
||||
created: parse_time(&mut hm, CREATED_FIELD)?,
|
||||
expires: parse_time(&mut hm, EXPIRES_FIELD)?,
|
||||
parsed_at: Utc::now(),
|
||||
|
@ -352,7 +352,7 @@ impl fmt::Display for DeprecatedAlgorithm {
|
|||
impl fmt::Display for Algorithm {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Algorithm::Hs2019 => write!(f, "{}", "hs2019"),
|
||||
Algorithm::Hs2019 => write!(f, "hs2019"),
|
||||
Algorithm::Deprecated(d) => d.fmt(f),
|
||||
Algorithm::Unknown(other) => write!(f, "{}", other),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue