A sales team builds a deal desk on Helix. Reps submit discount requests, and the finance lead approves them. Everyone on the team can open the app. Only finance should be able to approve a discount, and Jon in sales should never be able to approve his own.
Role-based access is how the app says so. The project config lists a finance role. The approveDiscount function is marked allowRoles: ['finance']. Maya in finance is assigned the role on the project’s Access Control tab. When Jon calls the function, he gets a 403 and his handler never runs. When Maya calls it, it goes through.
What that gives IT and the people building:
- The rule lives next to the function. Whoever reads
approveDiscountsees who may call it, and the SDK enforces it before the handler runs. - Roles are managed outside the app. Admins add and remove roles per person in the dashboard. Nothing needs a redeploy.
- Deny always wins. Block a role from one function, and holding another allowed role does not get around it.
- A record of every change. Each role assignment and removal lands in the organization’s activity trail.
An example
The deal desk has three kinds of function: request a discount, view the queue, approve a discount. The team wants reps to do the first two and finance to do the third.
1. Declare the roles
In helix.config.ts, the team adds a roles map with finance and sales. The key is the role id used in code and the value is the name admins see in the dashboard. Roles are picked up on every deploy.
2. Put a rule on the function
approveDiscount exports an access rule that allows the finance role. The functions for requesting and viewing have no rule, so anyone who can open the app can use them.
3. Assign people
On the project’s Access Control tab, under Users, a Contributor or Admin picks the people and their roles. Maya gets finance. Jon and Lin get sales. Add people and their roles in one step, or edit roles later from the row.
4. Try it as someone else
Before the team deploys, a developer runs the app locally as a sales user, with helix dev --identity ./.helix/identities/sales.json. Calling approveDiscount returns the same 403 a rep would get in production.
What follows from how it works
- Roles narrow access, they don’t grant it. A person still needs access to the app to use any role.
- Anonymous callers hold no roles.
allowRolesrefuses them, and a function with onlydenyRoleslets them through. - It covers HTTP functions. Schedules and MCP tools are not checked by the access rule.
- Removing a role from config keeps assignments. They grant nothing until the role is declared again, and the dashboard marks them.
- Removing someone from the app removes their roles.
Before you start
Update the SDK and CLI. Roles need @trayai/helix-sdk and @trayai/helix-cli 1.34.0 or later.
Test deny rules with an identity file. The default helix dev user holds every role you declare, so allowRoles never blocks you locally. Use an identity file or the X-Helix-Dev-Roles header to try fewer roles.
Handle a real user in dev. Before 1.34.0, ctx.identity was null in helix dev. Code that assumed that now sees a real dev user.