Actions is Now Generally Available

We’re excited to announce the general availability of Actions, which simplifies your custom workflows for extending Auth0 and offers an improved developer experience from Rules and Hooks!

Want to find out more about Actions? Check out the blog post below and let us know if you have any questions!

5 Likes

Looks great, really pleased to see some level of typing! Are the Auth0 Action types open source as we’d really like to write our actions in TS because writing critical code like this in JS is terrifying? i.e. this isn’t possible currently:

const getRoles = (event: Event) => {
  if (event.authorization.roles) {
    return event.authorization.roles;
  }
  // Handle legacy role
  if (event.user.app_metadata.role) {
    return [event.user.app_metadata.role];
  }
  return [];
}

const setRoles = (event: Event, roles: string[]) => {
    event.accessToken.setCustomClaim(withNamespace('roles'), roles);
    event.idToken.setCustomClaim(withNamespace('roles'), roles);
}

exports.onExecutePostLogin = async (event, api) => {
  const roles = getRoles(event);
  if (roles) {
    setRoles(event, roles);
  }
};

For rules, we currently author them in our own environment and compile with TS – which we could do with Actions, but would need the Auth0 action types, e.g. Event / PostLoginAPI etc.

3 Likes

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