Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"logfile": "log.log",
"address": "0.0.0.0",
"port": 3344,
"secret": "secret",
"repositories": [
{
"name": "foo",
Expand Down
10 changes: 9 additions & 1 deletion gitlab-webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Config struct {
Address string
Port int64
Repositories []ConfigRepository
Secret string
}

func PanicIf(err error, what ...string) {
Expand Down Expand Up @@ -141,7 +142,14 @@ func hookHandler(w http.ResponseWriter, r *http.Request) {
log.Println(r)
}
}()


//Check secret token
if config.Secret != "" {
if config.Secret != r.Header.Get("X-Gitlab-Token") {
PanicIf(errors.New("Invalid token"), "X-Gitlab-Token is different than specified in config")
}
}

var hook Webhook

//read request body
Expand Down