Hook

Hooks are secure, self-contained functions that allow you to customize the behavior of Auth0 when executed for selected extensibility points of the Auth0 platform. Auth0 invokes Hooks during runtime to execute your custom Node.js code.

Depending on the extensibility point, you can use Hooks with Database Connections and/or Passwordless Connections.

Example Usage

using Pulumi;
using Auth0 = Pulumi.Auth0;

class MyStack : Stack
{
    public MyStack()
    {
        var myHook = new Auth0.Hook("myHook", new Auth0.HookArgs
        {
            Dependencies = 
            {
                { "auth0", "2.30.0" },
            },
            Enabled = true,
            Script = @"function (user, context, callback) {
  callback(null, { user });
}

",
            TriggerId = "pre-user-registration",
        });
    }

}
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-auth0/sdk/v2/go/auth0"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := auth0.NewHook(ctx, "myHook", &auth0.HookArgs{
			Dependencies: pulumi.StringMap{
				"auth0": pulumi.String("2.30.0"),
			},
			Enabled:   pulumi.Bool(true),
			Script:    pulumi.String(fmt.Sprintf("%v%v%v%v", "function (user, context, callback) {\n", "  callback(null, { user });\n", "}\n", "\n")),
			TriggerId: pulumi.String("pre-user-registration"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_auth0 as auth0

my_hook = auth0.Hook("myHook",
    dependencies={
        "auth0": "2.30.0",
    },
    enabled=True,
    script="""function (user, context, callback) {
  callback(null, { user });
}

""",
    trigger_id="pre-user-registration")
import * as pulumi from "@pulumi/pulumi";
import * as auth0 from "@pulumi/auth0";

const myHook = new auth0.Hook("my_hook", {
    dependencies: {
        auth0: "2.30.0",
    },
    enabled: true,
    script: `function (user, context, callback) {
  callback(null, { user });
}
`,
    triggerId: "pre-user-registration",
});

Create a Hook Resource

new Hook(name: string, args: HookArgs, opts?: CustomResourceOptions);
@overload
def Hook(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         dependencies: Optional[Mapping[str, Any]] = None,
         enabled: Optional[bool] = None,
         name: Optional[str] = None,
         script: Optional[str] = None,
         secrets: Optional[Mapping[str, Any]] = None,
         trigger_id: Optional[str] = None)
@overload
def Hook(resource_name: str,
         args: HookArgs,
         opts: Optional[ResourceOptions] = None)
func NewHook(ctx *Context, name string, args HookArgs, opts ...ResourceOption) (*Hook, error)
public Hook(string name, HookArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args HookArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args HookArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args HookArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args HookArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Hook Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Hook resource accepts the following input properties:

Script string
Code to be executed when this hook runs
TriggerId string
Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message
Dependencies Dictionary<string, object>
Dependencies of this hook used by webtask server
Enabled bool
Whether the hook is enabled, or disabled
Name string
Name of this hook
Secrets Dictionary<string, object>
The secrets associated with the hook
Script string
Code to be executed when this hook runs
TriggerId string
Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message
Dependencies map[string]interface{}
Dependencies of this hook used by webtask server
Enabled bool
Whether the hook is enabled, or disabled
Name string
Name of this hook
Secrets map[string]interface{}
The secrets associated with the hook
script string
Code to be executed when this hook runs
triggerId string
Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message
dependencies {[key: string]: any}
Dependencies of this hook used by webtask server
enabled boolean
Whether the hook is enabled, or disabled
name string
Name of this hook
secrets {[key: string]: any}
The secrets associated with the hook
script str
Code to be executed when this hook runs
trigger_id str
Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message
dependencies Mapping[str, Any]
Dependencies of this hook used by webtask server
enabled bool
Whether the hook is enabled, or disabled
name str
Name of this hook
secrets Mapping[str, Any]
The secrets associated with the hook

Outputs

All input properties are implicitly available as output properties. Additionally, the Hook resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing Hook Resource

Get an existing Hook resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: HookState, opts?: CustomResourceOptions): Hook
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        dependencies: Optional[Mapping[str, Any]] = None,
        enabled: Optional[bool] = None,
        name: Optional[str] = None,
        script: Optional[str] = None,
        secrets: Optional[Mapping[str, Any]] = None,
        trigger_id: Optional[str] = None) -> Hook
func GetHook(ctx *Context, name string, id IDInput, state *HookState, opts ...ResourceOption) (*Hook, error)
public static Hook Get(string name, Input<string> id, HookState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Dependencies Dictionary<string, object>
Dependencies of this hook used by webtask server
Enabled bool
Whether the hook is enabled, or disabled
Name string
Name of this hook
Script string
Code to be executed when this hook runs
Secrets Dictionary<string, object>
The secrets associated with the hook
TriggerId string
Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message
Dependencies map[string]interface{}
Dependencies of this hook used by webtask server
Enabled bool
Whether the hook is enabled, or disabled
Name string
Name of this hook
Script string
Code to be executed when this hook runs
Secrets map[string]interface{}
The secrets associated with the hook
TriggerId string
Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message
dependencies {[key: string]: any}
Dependencies of this hook used by webtask server
enabled boolean
Whether the hook is enabled, or disabled
name string
Name of this hook
script string
Code to be executed when this hook runs
secrets {[key: string]: any}
The secrets associated with the hook
triggerId string
Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message
dependencies Mapping[str, Any]
Dependencies of this hook used by webtask server
enabled bool
Whether the hook is enabled, or disabled
name str
Name of this hook
script str
Code to be executed when this hook runs
secrets Mapping[str, Any]
The secrets associated with the hook
trigger_id str
Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message

Package Details

Repository
https://github.com/pulumi/pulumi-auth0
License
Apache-2.0
Notes
This Pulumi package is based on the auth0 Terraform Provider.