Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs - v1beta2 - Providers - Key type #581

Closed
michaelsatish opened this issue Jul 21, 2023 · 2 comments · Fixed by #585
Closed

Docs - v1beta2 - Providers - Key type #581

michaelsatish opened this issue Jul 21, 2023 · 2 comments · Fixed by #585

Comments

@michaelsatish
Copy link
Contributor

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
}
@somtochiama
Copy link
Member

@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?

@michaelsatish
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants