mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-25 19:01:01 +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(
|
||||
&mut self,
|
||||
algorithm: Option<Algorithm>,
|
||||
_key_id: &str,
|
||||
key_id: &str,
|
||||
signature: &str,
|
||||
signing_string: &str,
|
||||
) -> Self::Future {
|
||||
|
@ -23,6 +23,10 @@ impl SignatureVerify for MyVerify {
|
|||
_ => return Err(MyError::Algorithm),
|
||||
};
|
||||
|
||||
if key_id != "my-key-id" {
|
||||
return Err(MyError::Key);
|
||||
}
|
||||
|
||||
let decoded = base64::decode(signature).map_err(|_| MyError::Decode)?;
|
||||
|
||||
Ok(decoded == signing_string.as_bytes())
|
||||
|
@ -61,6 +65,9 @@ enum MyError {
|
|||
|
||||
#[fail(display = "Couldn't decode signature")]
|
||||
Decode,
|
||||
|
||||
#[fail(display = "Invalid key")]
|
||||
Key,
|
||||
}
|
||||
|
||||
impl ResponseError for MyError {
|
||||
|
|
Loading…
Reference in a new issue