travis_hook.go
func (t TravisHook) handleSignature(r *http.Request, secret string) error {
	signature := r.Header.Get("Authorization")
	if signature == "" {
		return errors.New("request sent no authorization signature")
	}
	if secret == "" {
		Logger().Print("Unable to verify request signature. Secret not set in caddyfile!\n")
		return nil
	}

	content := r.Header.Get("Travis-Repo-Slug") + secret
	hash := sha256.Sum256([]byte(content))
	expectedMac := hex.EncodeToString(hash[:])
	if signature != expectedMac {
		fmt.Println(signature, expectedMac)
		return errors.New("Invalid authorization header")
	}
	return nil
}
func (t TravisHook) handleSignature(r *http.Request, secret string) error {
	signature := r.Header.Get("Authorization")
	if signature == "" {
		return errors.New("request sent no authorization signature")
	}
	if secret == "" {
		Logger().Print("Unable to verify request signature. Secret not set in caddyfile!\n")
		return nil
	}

	content := r.Header.Get("Travis-Repo-Slug") + secret
	hash := sha256.Sum256([]byte(content))
	expectedMac := hex.EncodeToString(hash[:])
	if signature != expectedMac {
		fmt.Println(signature, expectedMac)
		return errors.New("Invalid authorization header")
	}
	return nil
}
func ( t TravisHook ) handleSignature ( r * http . Request , secret string ) error { signature := r . Header . Get ( " " ) if signature == " " { return errors . New ( " " ) } if secret == " " { Logger ( ) . Print ( " \n " ) return nil } content := r . Header . Get ( " " ) + secret hash := sha256 . Sum256 ( [ ] byte ( content ) ) expectedMac := hex . EncodeToString ( hash [ : ] ) if signature != expectedMac { fmt . Println ( signature , expectedMac ) return errors . New ( " " ) } return nil }
// Check for an authorization signature in the request. Reject if not present. If validation required, check the sha
Check for an authorization signature in the request . Reject if not present . If validation required check the sha