clientMetadata
—especially when checking against a single clientMetadata
value, common across multiple applications. Using clientMetadata
can also make adding new clients (as well as reading rule code) easier, especially if you have a large number of applications defined, by reducing the code changes or configuration values needed between environments.
Client metadata for an application can be set manually via the by going to Application Settings > Advanced Settings > Application Metadata or programmatically via the use of the Auth0 ’s Update a client endpoint.
return
in order to exit the (rule) function. To learn more, read Rules Execution Best Practices.
global
object can be used to cache information from API calls, which can subsequently be used across all rules that execute in the pipeline. Prefer to use this to store information instead of repeatedly calling an API. Additionally, the global
object can also be used to cache other information between executing rules.
auth0
object (so be sure to use it sparingly). To learn more, read Management API Endpoint Rate Limits.
In addition, Management API functions take varying degrees of time to perform, so will incur varying degrees of latency; calling the Management API’s List or Search users endpoint, for example, should be kept to a minimum and performed only where absolutely necessary—even when executed via the auth0
object.
context
object, so you can obtain connection info from the context
object instead of needing to call the Auth0 Management API. To learn more, read Context Object Properties in Rules.
To see this in action, if you are using the Check if user email domain matches configured domain rule template, check out the latest version on Github or navigate to Auth0 Dashboard > Auth Pipeline > Rules, and select Create. Note: the recent changes will not alter functionality but will improve the performance of rules that had once relied on calls to the Management API.
Removing calls to the Management API (as well as the extra call required to get the appropriate Access Token) will make your rule code perform better and be more reliable.
/.well-known/*
responses: This information does not change frequently, so you can usually cache it to reduce the number of times you need to call Auth0.id_token
instead of calling /userinfo
to get information about the user.