Comments (4)
Alright, here's a working example of GitHub signature verification for Deno:
import { Buffer } from "https://deno.land/std/io/mod.ts";
import { timingSafeEqual } from "https://deno.land/std/node/crypto.ts";
import { hmac } from "https://deno.land/x/[email protected]/mod.ts";
const encoder = new TextEncoder()
const signature = req.headers.get(`x-hub-signature`) ?? ``;
const signatureBuffer = encoder.encode(signature);
const payload = await req.body({ type: `text` }).value;
const algorithm = signature.startsWith("sha256=") ? "sha256" : "sha1";
const verification = `${algorithm}=${hmac(algorithm, "helloworld", payload, "utf8", "hex")}`;
const verificationBuffer = encoder.encode(verification);
// constant time comparison to prevent timing attachs
// https://stackoverflow.com/a/31096242/206879
// https://en.wikipedia.org/wiki/Timing_attack
const matchesSignature = signatureBuffer.length === verificationBuffer.length
&& await timingSafeEqual(signatureBuffer, verificationBuffer);
from webhooks-methods.js.
I accidentally clicked on 'bug'. The bug label might not be accurate.
from webhooks-methods.js.
I'm experiencing the same problem with both X-Hub-Signature
and X-Hub-Signature-256
.
from webhooks-methods.js.
I already made it working with https://stackoverflow.com/a/71088170/10379728.
from webhooks-methods.js.
Related Issues (6)
- Action Required: Fix Renovate Configuration
- βverifyβ should not detect the algorithm from the unverified signature HOT 2
- "module" entry points to web bundle HOT 4
- verify: does not gracefully handle invalid signatures HOT 10
- [BUG]: docs for how to stringify parsed objects/payloads does not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webhooks-methods.js.