Problem statement
We need to begin migrating our existing Rules and Hooks to Actions as Rules and Hooks will reach the end of life on November 18, 2024.
Symptoms
Key Dates for the Deprecation
-
October 16, 2023 - Rules and Hooks will no longer be available for tenants of new and existing customers.
-
Existing tenants using Rules and Hooks will maintain access to those features until EOL but are highly encouraged to start the migration to Actions as soon as possible.
-
November 18, 2024 - Rules and Hooks will reach end of life and will be removed from all tenants . In practical terms, this will mean Rules and Hooks currently configured in a given tenant will no longer execute during the login pipeline.
Solution
Migrating from Rules to Actions can be broken down into four main steps:
- Plan your migration: Post-Login Actions run after existing Rules, so you can either convert Rules one at a time in the Dashboard or all at once using the Management API. Tips when planning your migration:
- Keep your Actions and Rules 1:1, so functionality can be turned off and on in blocks and tested.
- Use flags in user metadata to avoid duplicating expensive or one-time operations.
- Start at the end of your Rules pipeline and work backward; because active Rules run before deployed Actions, you can keep some logic in Rules as you build and test other logic in Actions.
- Make sure to run changes at a time when impact and traffic will be lowest.
- Consider temporarily customizing your login page to halt logins if the cutover could cause invalid logins or gaps in protection.
- Consider using the Auth0 Deploy CLI to script, test, and quickly implement the migration all at once or iteratively.
-
Understand limitations: While Actions can handle the vast majority of things that Rules can, you should be aware of a few limitations before you start your migration. (Remember: you can have both Rules and Actions running as you migrate.)
-
Convert code: To convert a Rule to an Action, you must replace Rule-specific code with Actions code. This section covers the tasks you will need to perform to turn a functioning Rule into its equivalent Action. Tips when converting code:
- In general, look for the read-only properties of Rules
user
andcontext
objects on the Actionsevent
object. Look for any side effects your Actions have on the system (like failing a login or updating user metadata) in theapi
object functions. - Use the Actions Code Editor in the Auth0 Dashboard to write your code; it will help by highlighting errors and supplying auto-complete suggestions.
- Before you go live, thoroughly test your new Actions in a staging or test environment.
- Complete the migration: Once your new Actions code has been written and tested, you must activate the Action and deactivate the Rule. These two tasks can be done quickly in succession, but depending on the order, there might be a short period of time where either both or neither are running. Because active Rules run before deployed Actions, if you start at the end of your Rules pipeline and work backward, you can keep some logic in Rules as you build and test other logic in Actions.