Refactor and verify http signature on personnal inbox

Verify signature on personnal inbox
Reduce code duplication
Put Headers in plume-models
This commit is contained in:
Trinity Pointard
2018-10-03 20:48:25 +02:00
parent 0a5d435249
commit 62c94ed463
5 changed files with 42 additions and 29 deletions
+9
View File
@@ -128,6 +128,15 @@ pub enum SignatureValidity {
Absent,
}
impl SignatureValidity {
pub fn is_secure(&self) -> bool {
match self {
SignatureValidity::Valid => true,
_ => false,
}
}
}
pub fn verify_http_headers<S: sign::Signer+::std::fmt::Debug>(sender: &S, all_headers: HeaderMap, data: String) -> SignatureValidity{
if let Some(sig_header) = all_headers.get_one("Signature") {
let mut _key_id = None;