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 authorization header in webhooks stored in secrets table #941

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

CamilleLegeron
Copy link
Collaborator

@CamilleLegeron CamilleLegeron commented Apr 18, 2024

@CamilleLegeron CamilleLegeron self-assigned this Apr 18, 2024
@CamilleLegeron CamilleLegeron marked this pull request as draft April 18, 2024 07:35
Copy link
Collaborator

@fflorent fflorent left a comment

Choose a reason for hiding this comment

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

Globally LGTM, few little remarks.

app/server/lib/DocApi.ts Outdated Show resolved Hide resolved
app/server/lib/Triggers.ts Outdated Show resolved Hide resolved
CamilleLegeron and others added 2 commits April 30, 2024 15:49
Authorizarion wuth capital A and add it in header call only if there is one

Co-authored-by: Florent <[email protected]>
@CamilleLegeron CamilleLegeron marked this pull request as ready for review April 30, 2024 15:21
@fflorent
Copy link
Collaborator

fflorent commented May 2, 2024

@CamilleLegeron Probably worth to take a look at the failures, I see some of them are related to Webhooks.

@@ -4889,6 +4891,7 @@ function testDocApi() {

const expectedFields = {
url: `${serving.url}/foo`,
authorization: '',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe also add a specific tests to ensure that a filled authorization header is passed to the webhook consumer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good remark, adding this test I find a bug when calling patch call : before when we used patch call to update URL without giving information of authorization it removed it

@CamilleLegeron
Copy link
Collaborator Author

Hi, I send you a notif @paulfitz to know if you can review this PR or maybe other person in Gristlabs

Copy link
Collaborator

@fflorent fflorent left a comment

Choose a reason for hiding this comment

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

I just have a simple question regarding your last addition.

app/gen-server/lib/HomeDBManager.ts Outdated Show resolved Hide resolved
@fflorent fflorent added the anct label Jun 13, 2024
'tableId', 'isReadyColumn',
'watchedColIdsText', 'webhookId',
'enabled', 'status'
'eventTypes', 'tableId',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why the order has changed? The comment mentions that the order matters here. Maybe it is outdated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because it's the order on the frontend too and I find this order more logical.

  • Having the authorization parameter next to the url
  • Having the table id next to the eventTypes
  • etc ..
    But if you thinks differently we can change it

Copy link
Contributor

Choose a reason for hiding this comment

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

No it looks fine. I'm just asking as this change wasn't mentioned anywhere (PR description or issue).

webhookSecret.url = url;
// As we want to patch the webhookSecret object, only set the url and the authorization when they are defined.
// When the user wants to empty the value, we are expected to receive empty strings.
if (url !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

2 things:

  • I'd convert arguments to an object, as there are too many strings there
  • I'd throw an exception when both those things are not defined.

If you take a look at the line 1939 updateSecret method, it will throw an exception if the update won't do anything, but with completely misleading error message - that the secret wasn't found, when in fact it was found but just not updated.

Btw: can you update that error message as well, to something like:
secret with given id not found or nothing was updated.

'Filter for changes in these columns (semicolon-separated ids)',
'Ready Column',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add/update one of this test to update the Authorization column and check that it is persisted ok.

@berhalak berhalak self-requested a review July 1, 2024 15:19
@berhalak
Copy link
Contributor

berhalak commented Jul 2, 2024

Hi @CamilleLegeron, it looks that something went wrong in the merge as there are lots of unrelated files changed.

@CamilleLegeron
Copy link
Collaborator Author

Hi @CamilleLegeron, it looks that something went wrong in the merge as there are lots of unrelated files changed.

Yes in fact, thanks. I saw the tests errors, I put the PR in draft to look at it

@CamilleLegeron CamilleLegeron marked this pull request as draft July 2, 2024 12:59
@CamilleLegeron CamilleLegeron marked this pull request as ready for review July 2, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

3 participants