mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-26 03:11:05 +00:00
Check key-id
This commit is contained in:
parent
f8791f770b
commit
fef18d96db
1 changed files with 8 additions and 1 deletions
|
@ -14,7 +14,7 @@ impl SignatureVerify for MyVerify {
|
||||||
fn signature_verify(
|
fn signature_verify(
|
||||||
&mut self,
|
&mut self,
|
||||||
algorithm: Option<Algorithm>,
|
algorithm: Option<Algorithm>,
|
||||||
_key_id: &str,
|
key_id: &str,
|
||||||
signature: &str,
|
signature: &str,
|
||||||
signing_string: &str,
|
signing_string: &str,
|
||||||
) -> Self::Future {
|
) -> Self::Future {
|
||||||
|
@ -23,6 +23,10 @@ impl SignatureVerify for MyVerify {
|
||||||
_ => return Err(MyError::Algorithm),
|
_ => return Err(MyError::Algorithm),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if key_id != "my-key-id" {
|
||||||
|
return Err(MyError::Key);
|
||||||
|
}
|
||||||
|
|
||||||
let decoded = base64::decode(signature).map_err(|_| MyError::Decode)?;
|
let decoded = base64::decode(signature).map_err(|_| MyError::Decode)?;
|
||||||
|
|
||||||
Ok(decoded == signing_string.as_bytes())
|
Ok(decoded == signing_string.as_bytes())
|
||||||
|
@ -61,6 +65,9 @@ enum MyError {
|
||||||
|
|
||||||
#[fail(display = "Couldn't decode signature")]
|
#[fail(display = "Couldn't decode signature")]
|
||||||
Decode,
|
Decode,
|
||||||
|
|
||||||
|
#[fail(display = "Invalid key")]
|
||||||
|
Key,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResponseError for MyError {
|
impl ResponseError for MyError {
|
||||||
|
|
Loading…
Reference in a new issue