Skip to content

nbtca/notification-center

Repository files navigation

notification-center

消息事件转发中心

  • 在配置的端口监听 http(s)请求,用于接收 http(webhook) 请求
  • 在配置的端口/ws 路径下监听 websocket 请求,连接到此 websocket 的客户端会收到转发自 http(webhook) 的请求消息

🚀 Deployment/部署

  • 🐳 Docker

    执行docker_build.sh,将构建并打包webhook.tar镜像文件,在运行环境执行docker load -i webhook.tar导入镜像

    • 启动命令(参考)
      touch notification-center.config.json
      docker run -d -p 8080:8080 --name webhook -v $(pwd)/notification-center.config.json:/config/config.json webhook

🛠️ Config/配置

{
  "bind": ":8080",
  "use_cert": false,
  "cert_file": "fullchain.cer",
  "key_file": "private.key",
  "auth": {
    "": "默认路径的密钥",
    "github": "对于/github路径的请求使用的密钥"
  }
}

🛡️ Authentication/鉴权

不论是 http(s) 还是 websocket 请求,都需要进行鉴权,鉴权方式如下二选一

  • Header["Authorization"]

    • 用于直接鉴权的密钥
    • 格式为Bearer ${value}${value}为配置文件中auth字段中的value对应的值
  • Header["X-Signature-256"]

    • SHA256签名,用于验证请求的合法性,通过auth字段中的value作为 HMAC 的密钥,对请求的body进行签名,签名结果与请求头中的X-Signature-256进行比对,如果一致则请求合法,否则请求非法

🎉 Sample/示例

client A 负责推送事件,使用POST请求发送到 service_1路径下(POST https://xxx.xxx/service_1),client B 通过 websocket 连接到 (POST wss://xxx.xxx/ws/service_1),此时client B 将收到 client A 推送的事件。

About

Bridge all webhook with a universal message center

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •