diff --git a/src/web.rs b/src/web.rs index ec9b0d6..dd5758b 100644 --- a/src/web.rs +++ b/src/web.rs @@ -56,10 +56,22 @@ async fn hooks_inner(req: Request, secret: &str) -> Result = vec![]; let whole_body = req.collect().await?.aggregate(); whole_body.reader().read_to_end(&mut payload)?; + + if let Some(val) = headers.get("X-Gitlab-Token") { + debug!("Found Gitlab payload"); + if secret != val { + return Err(Error::InvalidSecret); + } + + let hook: GitlabHook = serde_json::from_slice(&payload[..])?; + return Ok(Hook::Gitlab(hook)); + } + + // Generate hmac signature let mut mac = HmacSha256::new_from_slice(secret.as_bytes())?; mac.update(&payload); let result = mac.finalize().into_bytes(); @@ -76,14 +88,6 @@ async fn hooks_inner(req: Request, secret: &str) -> Result