代码之家  ›  专栏  ›  技术社区  ›  hendry

认证电子邮件回复

  •  0
  • hendry  · 技术社区  · 6 年前

    reply.github.com是如何工作的我注意到您可以回复Github电子邮件,例如:

    Reply-To: example/foobar <reply+000bafafcb72e8dc89884bda7ce639d101cc16b69010bcaa92cf0000000117ad897992a169ce14271668@reply.github.com>
    X-Auto-Response-Suppress: All
    

    回复:+${84_chars}@reply.github.com

    这足以附加您的消息:

    1. 特定的Github问题
    2. 以您的名义或用户名

    我的问题是,那是什么编码?

    这不是HMAC,因为我相信你需要用这种编码发送未加密的消息。

    1 回复  |  直到 6 年前
        1
  •  0
  •   hendry    6 年前

    毕竟,HMAC是答案没有必要隐藏我试图验证的数据。消息验证代码(MAC)成为我在后端验证的签名组件。

    const crypto = require('crypto')
    
    const secret = process.env.API_ACCESS_TOKEN
    
    function genreply (bugID, secret) {
      const hash = crypto.createHmac('sha256', secret)
        .update(bugID)
        .digest('hex')
    
      return `reply+${bugID}-${hash}@example.com`
    }
    
    console.log(genreply('61825', secret))