github: handle prefix in front of sha256 sig
This commit is contained in:
parent
9521afaf95
commit
04670d2be1
|
@ -24,6 +24,15 @@ fn validate_signature(secret: &str, signature: &str, data: &str) -> bool {
|
||||||
|
|
||||||
mac.update(data.as_bytes());
|
mac.update(data.as_bytes());
|
||||||
|
|
||||||
|
// GitHub puts a prefix in front of its hex SHA256
|
||||||
|
let signature = match signature.strip_prefix("sha256=") {
|
||||||
|
Some(s) => s,
|
||||||
|
None => {
|
||||||
|
trace!("couldn't strip prefix from signature `{}`", signature);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
match hex::decode(signature) {
|
match hex::decode(signature) {
|
||||||
Ok(bytes) => mac.verify(&bytes).is_ok(),
|
Ok(bytes) => mac.verify(&bytes).is_ok(),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
|
Loading…
Reference in a new issue