diff options
author | Wim <wim@42.be> | 2015-10-24 18:01:15 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2015-10-24 18:05:10 +0200 |
commit | 6feccd4c6cae08c7c6a4f283822565785428b2e0 (patch) | |
tree | f5d4b8f2fda0e16065eb07ac5f300d7dc0e9e1c4 /matterhook/matterhook.go | |
parent | 25d72a7e31a0d077546639f3de25d75ebb4efa14 (diff) | |
download | matterbridge-msglm-6feccd4c6cae08c7c6a4f283822565785428b2e0.tar.gz matterbridge-msglm-6feccd4c6cae08c7c6a4f283822565785428b2e0.tar.bz2 matterbridge-msglm-6feccd4c6cae08c7c6a4f283822565785428b2e0.zip |
Add support for outgoing webhook token
Diffstat (limited to 'matterhook/matterhook.go')
-rw-r--r-- | matterhook/matterhook.go | 11 |
1 files changed, 10 insertions, 1 deletions
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 } |