Skip to content

Commit

Permalink
Update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Aug 9, 2023
1 parent 75c15ea commit 7a0a169
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,24 @@ release:
test:
@echo 'todo'

docker:
docker run -p 3000:3000 hopprotocol/webhook-server

# Build docker target
docker-build:
docker build -f Dockerfile -t hopprotocol/webhook-server .

# Tag docker image
docker-tag:
$(eval REV=$(shell git rev-parse HEAD | cut -c1-7))
docker tag hopprotocol/webhook-server:latest hopprotocol/webhook-server:latest
docker tag hopprotocol/webhook-server:latest hopprotocol/webhook-server:$(REV)

# Push to registry
docker-push:
$(eval REV=$(shell git rev-parse HEAD | cut -c1-7))
docker push hopprotocol/webhook-server:latest
docker push hopprotocol/webhook-server:$(REV)

# Build docker image and push to registry
docker-build-and-push: docker-build docker-tag docker-push
14 changes: 10 additions & 4 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ func (s *Server) Handler(w http.ResponseWriter, r *http.Request) {
}

if s.secret != "" {
headerSig := r.Header.Get("X-Hub-Signature")
sig := hmacSig(s.secret, []byte(strings.TrimSpace(string(b))))
expectedSig := fmt.Sprintf("sha1=%x", sig)
if headerSig != expectedSig {
// headerSig := r.Header.Get("X-Hub-Signature")
// sig := hmacSig(s.secret, []byte(strings.TrimSpace(string(b))))
// expectedSig := fmt.Sprintf("sha1=%x", sig)
// if headerSig != expectedSig {
// w.WriteHeader(http.StatusUnauthorized)
// fmt.Fprintf(w, http.StatusText(http.StatusUnauthorized))
// return
// }
secret := r.Header.Get("X-Secret")
if secret != s.secret {
w.WriteHeader(http.StatusUnauthorized)
fmt.Fprintf(w, http.StatusText(http.StatusUnauthorized))
return
Expand Down

0 comments on commit 7a0a169

Please sign in to comment.