mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-25 21:49:43 +01:00
Add support for outgoing webhook token
This commit is contained in:
parent
25d72a7e31
commit
6feccd4c6c
@ -57,6 +57,9 @@ url="http://mattermost.yourdomain.com/hooks/incomingwebhookkey"
|
|||||||
#port the bridge webserver will listen on
|
#port the bridge webserver will listen on
|
||||||
port=9999
|
port=9999
|
||||||
showjoinpart=true #show irc users joining and parting
|
showjoinpart=true #show irc users joining and parting
|
||||||
|
#the token you get from the outgoing webhook in mattermost. If empty no token check will be done.
|
||||||
|
token=yourtokenfrommattermost
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### mattermost
|
### mattermost
|
||||||
|
@ -19,6 +19,7 @@ type Config struct {
|
|||||||
URL string
|
URL string
|
||||||
Port int
|
Port int
|
||||||
ShowJoinPart bool
|
ShowJoinPart bool
|
||||||
|
Token string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,3 +10,4 @@ channel="#matterbridge"
|
|||||||
url="http://yourdomain/hooks/yourhookkey"
|
url="http://yourdomain/hooks/yourhookkey"
|
||||||
port=9999
|
port=9999
|
||||||
showjoinpart=true
|
showjoinpart=true
|
||||||
|
#token=yourtokenfrommattermost
|
||||||
|
@ -19,7 +19,8 @@ type Bridge struct {
|
|||||||
func NewBridge(name string, config *Config) *Bridge {
|
func NewBridge(name string, config *Config) *Bridge {
|
||||||
b := &Bridge{}
|
b := &Bridge{}
|
||||||
b.Config = config
|
b.Config = config
|
||||||
b.m = matterhook.New(b.Config.Mattermost.URL, matterhook.Config{Port: b.Config.Mattermost.Port})
|
b.m = matterhook.New(b.Config.Mattermost.URL,
|
||||||
|
matterhook.Config{Port: b.Config.Mattermost.Port, Token: b.Config.Mattermost.Token})
|
||||||
b.i = b.createIRC(name)
|
b.i = b.createIRC(name)
|
||||||
go b.handleMatter()
|
go b.handleMatter()
|
||||||
return b
|
return b
|
||||||
|
@ -45,8 +45,10 @@ type Client struct {
|
|||||||
Config
|
Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Config for client.
|
||||||
type Config struct {
|
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.
|
// New Mattermost client.
|
||||||
@ -96,6 +98,13 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
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
|
c.In <- msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user