Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the implementation of generating webhook signature when there are special characters in the payload #260

Open
yqrashawn opened this issue Aug 16, 2024 · 0 comments
Labels
question Further information is requested

Comments

@yqrashawn
Copy link

Question description

When there are special characters in the payload
For example
ä, ü, ö, 任务

I got the “wrong” signature following the X-Todoist-Hmac-SHA256 doc in the Request Header section of the sync doc.

example code

const c = require("node:crypto");
const hash = c.createHmac("sha256", secret).update(buf).digest("base64");
(def payload (slurp body :encoding "UTF-8"))
;; body is jetty HttpInputStream http://www.servlets.com/javadoc/org/mortbay/http/HttpInputStream.html
(defn hmac-sha256-b64 [secret payload]
  (-> payload
      buddy.codecs/str->bytes
      (buddy.mac/hash {:key secret :alg :hmac+sha256})
      buddy.codecs/bytes->b64-str))
  • the two implementations have the same result
  • signature matches with the one in X-Todoist-Hmac-SHA256 when there's no special character
@yqrashawn yqrashawn added the question Further information is requested label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant