Check key-id

This commit is contained in:
asonix 2019-09-13 18:12:12 -05:00
parent f8791f770b
commit fef18d96db

View file

@ -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 {