Deploy CLI Tool: How to access a role id from within a rule?

Hi,

In my tenant.yaml I’d like to create a role admin and a rule addRoleToUser that assigns the admin role to the user after signup.

I have the following setting for the first part:

roles:
  - name: admin
    description: Admin
    permissions:
      - permission_name: 'read:admin-dashboard'
        resource_server_identifier: website

and the following for the rule:

- name: Set user roles after signup
    script: ./rules/addAdminRoleToNewUser.js
    stage: login_success
    enabled: true
    order: 2

The rule uses the management API to assign the role to the user (management.users.assignRoles(...)), but to do so I need the id of the role.

How can I pass the role id to the rule so that it can be used by the script? I’m aware that there is a rulesConfigs prop to set config values that can be used in the rule. Would this be the recommended way? How would I set the value here to the id of the admin role that was created above?

rulesConfigs: 
  - key: "ADMIN_ROLE_ID"
    value: ???

Hey there!

As this topic is related to Rules - Hooks - Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!