Skip to content

Commit

Permalink
refactor: rollback signature verification
Browse files Browse the repository at this point in the history
  • Loading branch information
vitoUwu committed Nov 11, 2024
1 parent a1fe3c0 commit cf8cd4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions actions/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ export default async function action(
req: Request,
ctx: AppContext & DrizzleContext,
) {
const signature = req.headers.get("x-hub-signature-256");

if (!signature) {
console.error("Signature is missing. Request Headers:", req.headers);
return new Response("Signature is missing", {
status: STATUS_CODE.BadRequest,
});
}

if (!("repository" in props) || !props.repository) {
console.error("Repository is missing. Request Body:", props);
return new Response("Repository is missing", {
Expand Down Expand Up @@ -60,11 +69,9 @@ export default async function action(
}

const secret = project.github.webhook_secret?.get();
const signature = req.headers.get("x-hub-signature-256");

if (
secret &&
signature &&
!(await verify(secret, JSON.stringify(props), signature))
) {
console.error("Invalid signature. Data:", { project, props });
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"version": "0.2.1",
"version": "0.2.2",
"lock": false
}

0 comments on commit cf8cd4e

Please sign in to comment.