From 6feccd4c6cae08c7c6a4f283822565785428b2e0 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 24 Oct 2015 18:01:15 +0200 Subject: Add support for outgoing webhook token --- matterhook/matterhook.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'matterhook') diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go index 8e87cc7b..ed062499 100644 --- a/matterhook/matterhook.go +++ b/matterhook/matterhook.go @@ -45,8 +45,10 @@ type Client struct { Config } +// Config for client. type Config struct { - Port int + Port int // Port to listen on. + Token string // Only allow this token from Mattermost. (Allow everything when empty) } // New Mattermost client. @@ -96,6 +98,13 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } + if c.Token != "" { + if msg.Token != c.Token { + log.Println("invalid token " + msg.Token + " from " + r.RemoteAddr) + http.NotFound(w, r) + return + } + } c.In <- msg } -- cgit v1.2.3