@@ -87,26 +87,6 @@ void startServer(HTTPServerSettings settings)
8787// Github hook
8888// ==============================================================================
8989
90- auto getSignature (string data)
91- {
92- import std.digest.digest , std.digest.hmac , std.digest.sha ;
93- import std.string : representation;
94-
95- auto hmac = HMAC ! SHA1 (hookSecret.representation);
96- hmac.put(data.representation);
97- return hmac.finish.toHexString! (LetterCase.lower);
98- }
99-
100- Json verifyRequest (string signature, string data)
101- {
102- import std.exception : enforce;
103- import std.string : chompPrefix;
104-
105- enforce(getSignature(data) == signature.chompPrefix(" sha1=" ),
106- " Hook signature mismatch" );
107- return parseJsonString (data);
108- }
109-
11090void trelloHook (HTTPServerRequest req, HTTPServerResponse res)
11191{
11292 import std.array : array;
@@ -130,6 +110,7 @@ void trelloHook(HTTPServerRequest req, HTTPServerResponse res)
130110void githubHook (HTTPServerRequest req, HTTPServerResponse res)
131111{
132112 import std.functional : toDelegate;
113+ import dlangbot.github : verifyRequest;
133114
134115 auto json = verifyRequest(req.headers[" X-Hub-Signature" ], req.bodyReader.readAllUTF8);
135116 switch (req.headers[" X-GitHub-Event" ])
0 commit comments