GitHub deployment and hooks - incorrect docs(?)

Hi,

On this page - https://auth0.com/docs/extensions/github-deployments

It states

The GitHub Deployments extension allows you to deploy rules, rule configs, hooks, connections, database connection scripts, clients, client grants, resource servers, Universal Login pages, and email templates from GitHub to Auth0.

In particular the mention of ‘hooks’.

But in the deployment folder list there is no ‘hooks’ directory listed.

On the hooks doc page - https://auth0.com/docs/hooks

There is no mention of being able to use GitHub deployment to manage hooks.

So simple question, can hooks be managed using GitHub deployments extension or only via the methods (dashboard, management API and CLI) mentioned in the hooks documentation?

Thanks.

Hey there!

I guess there might be some mistake in the first doc. Indeed, you can use dashboard, Management API and CLI to manage Hooks, that’s for sure.

I just checked the GitHub Deployments extension doc you mentioned and there is one mention about hooks but nothing more than that so I would assume that it’s not doable to manage hooks using that tool as the doc doesn’t mention precisely how to achieve that. Will relay it to our docs team

1 Like

Thanks Konrad!

I had a feeling it might be something incorrect in the docs.

It would be very useful if the hook config could be deployed from Github though!

1 Like

Yep it sounds like a great feature. Would you mind submitting it through our product feedback form?

I was able to deploy Auth0 Hooks using GitHub.

In order to do so create a hooks directory the root of your repository. In that folder for each hook create 2 files: .js file for the hook itself and .json file to make this work. The structure of .js file is the same as it would be in the dashboard. In my case .json file looks something like that

{
    "name": "PreRegistrationHook",
    "enabled": true,
    "triggerId": "pre-user-registration"
}

Beware that when you deploy a code with a hook it does not rewrite the old one, it just creates a new hook. And since Auth0 has its limitations about the number of hooks after some number of deploys you will not be able to deploy your repository until you delete some of your hooks.

All that was written above works for pre-user-registration hook.

If you need hook for other event, then try using one of the following: credentials-exchange , post-user-registration , post-change-password .

The problem is I tried to create a Post Registration Hook with similar structure (by replacing the name and the triggerId), but on every deploy I was receiving the error like this one:

Problem creating hooks {"name":"PostRegistrationHook","triggerId":"post-user-registration"}
APIError: {"statusCode":400,"error":"Bad Request","message":"Error: Webtask error Invalid payload: ValidationError: child \"meta\" fails because [child \"auth0-extension-secret\" fails because [\"auth0-extension-secret\" is not allowed to be empty]]","errorCode":"WebtaskError"}
1 Like

Thanks I’ll give that a go.

I did have a hooks folder when I did a deploy the other day and it gave a pretty non-descript error about what is missing.

Schema validation failed loading [
{
    "keyword": "required",
    "dataPath": ".hooks[0]",
    "schemaPath": "#/properties/hooks/items/required",
    "params": {
        "missingProperty": "name"
    },
    "message": "should have required property 'name'"
}
]

But your post makes sense now that it must have been referring to the .json file that I didn’t have included.

Found solution to my problem. It seems that you can successfully deploy hooks only if you do not have any active ones in your Auth0 application at the moment of deploy. The error message is confusing, but in fact you just have to disable/delete the currently active hook.

Also, I wasn’t able to create a configs directory for hooks, so using the mappings was the solution for me to store some values.

1 Like

Thanks for sharing all that here!

I’ll make sure to relay feedback to appropriate team!

Are you going to support hooks deployment?

It is negating the purpose of using Github Deployment, you need to do a manual step across all the tenants in order to be able to apply the change.

Cześć Łukasz!

We are aware of that. I relayed the feedback to our product team and the best I can do to advocate for this feature is to mention that again. Will do that! The more people advocate for this feature of course the more likely it is to get implemented. As of now there is no ETA on that.

Cześć Konrad!

Thanks for the response.
If there is no ETA for the fix, it would be good to be able to add hooks to excluded list and ignore for time being (same as Clients, Rules etc.)

I’m also having another issue, after manually deleting all the hooks from the tenant and deploy

“Insufficient scope, expected any of: create:hooks”

Could you please advise ?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.