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

Add "generic-hmac" Provider #426

Merged
merged 1 commit into from
Oct 5, 2022
Merged

Add "generic-hmac" Provider #426

merged 1 commit into from
Oct 5, 2022

Conversation

makkes
Copy link
Member

@makkes makkes commented Sep 30, 2022

This commit adds the "generic-hmac" Provider type for authenticating
webhook requests coming from notification-controller. I extended the
Forwarder notifier to accept an optional key used for generating the
HMAC. If the key is nil or empty no HMAC header is generated and the
forwarder behaves as before. If it is provided an X-Signature HTTP
header is added to the request carrying the HMAC.

I transformed the TestForwarder_Post test into a table-driven test
so that we can use the same setup and testing code for testing HMAC
and non-HMAC forwarder instances.

The Flux CLI will support this new type automatically as it doesn't validate the given type by itself (this is done by the API server using the CRD spec.

closes #99

@makkes makkes requested a review from pjbgf September 30, 2022 13:15
@makkes makkes self-assigned this Sep 30, 2022
@makkes makkes added the enhancement New feature or request label Sep 30, 2022
@makkes makkes force-pushed the generic-hmac-provider branch 2 times, most recently from 1ea26c2 to 70b804b Compare September 30, 2022 13:31
@makkes makkes force-pushed the generic-hmac-provider branch 2 times, most recently from cb3ee2d to bebb27d Compare September 30, 2022 14:49
internal/notifier/forwarder.go Outdated Show resolved Hide resolved
internal/notifier/forwarder_test.go Show resolved Hide resolved
This commit adds the "generic-hmac" Provider type for authenticating
webhook requests coming from notification-controller. I extended the
`Forwarder` notifier to accept an optional key used for generating the
HMAC. If the key is nil or empty no HMAC header is generated and the
forwarder behaves as before. If it is provided an `X-Signature` HTTP
header is added to the request carrying the HMAC.

I transformed the `TestForwarder_Post` test into a table-driven test
so that we can use the same setup and testing code for testing HMAC
and non-HMAC forwarder instances.

Any existing `X-Signature` header value set through
a `Provider.spec.secretRef` Secret's `header` field will be
overwritten.

closes #99

Signed-off-by: Max Jonas Werner <max@e13.dev>
Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @makkes! 🙇

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

Successfully merging this pull request may close these issues.

Allow signing of generic webhook provider requests
2 participants