fluxcd / notification-controller

The GitOps Toolkit event forwarded and notification dispatcher

Home Page:https://fluxcd.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docs - v1beta2 - Providers - Key type

michaelsatish opened this issue · comments

There is a type issue in the example provided for Generic Webhook with HMAC.

https://github.com/fluxcd/notification-controller/blob/main/docs/spec/v1beta2/providers.md#generic-webhook-with-hmac

The function verifySignature takes a key of type byte array.

func verifySignature(signature string, payload, key []byte) error

A string value is provided to the function when it gets called in the handleRequest function

// Verify signature using the same token as the Secret referenced in
// Provider
key := "<token>"
if err := verifySignature(r.Header.Get("X-Signature"), body, key); err != nil {
    http.Error(w, fmt.Sprintf("failed to verify HMAC signature: %s", err.Error()), http.StatusBadRequest)
    return
}

@michaelsatish thanks for catching this.

The key can be converted to a byte array. as it is passed to the function.
Would you like to open a PR for it?

@somtochiama More than happy to open a PR. Opened PR #585