Permissions and roles
The menu the user sees is not the menu you saved — it's the menu filtered to what the user is allowed to use. Liberty prunes the tree at fetch time so users never click on items they can't open.
Two filters apply:
| Filter | When it kicks in |
|---|---|
| Implicit permission | Every leaf inherits the permission of its target — sql:<connector>:<target> for a query, api:<connector>:<target> for an endpoint. Users without the permission don't see the leaf. |
| Explicit roles | The leaf's roles field is an additional gate — when set, the user must have at least one of the listed roles. |
After both filters run, folders with no surviving children are collapsed away.
At a glance
The implicit permission
Every leaf is gated by the permission of its target:
type | Required permission |
|---|---|
screen, query | sql:<connector>:<target> (the query's permission). |
endpoint | api:<connector>:<target> (the endpoint's permission). |
dashboard | The permission of at least one of its data widgets, or dashboard:<id> — see below. |
page | The page's own: explorer:<app>:<model> for the Data Explorer, page:<app>:<page> for a page an application ships, nomaflow:view for the Nomaflow pages, tests:view for the Tests pages, none for the others. |
A role that sets the entry, its folder or the whole application to Read (menu:<app>:<id>) or Read and change (edit:<app>:<id>) also shows the leaf: the server gives it what the screen needs, its target's permission included. A menu: deny always hides it. The role editor writes these strings from its menu tree — see Roles and permissions.
A user with sql:crm:customers_get sees the menu leaf that opens the Customers screen. A user without it doesn't — the leaf vanishes from the rendered menu.
This is the same permission the screen / endpoint already checks. The menu doesn't introduce a second permission; it just hides links the user couldn't follow anyway. Result: no greyed-out items, no clicks that take the user to a 403 forbidden page.
The explicit roles filter
The roles field on a menu item is a list of role names. When set:
- The user must have at least one of the listed roles.
- The check is in addition to the implicit permission — both must hold.
roles value | Behaviour |
|---|---|
| Empty (default) | Visibility determined by the implicit permission alone. |
["manager"] | Visible only to users with the manager role. |
["manager", "admin"] | Visible to users with either manager or admin. |
Use cases
| Pattern | Example |
|---|---|
| Hide an item that's open to read but only meaningful for a subset of users. | A Reports leaf where every user has read on the underlying query, but only managers actually use it. |
| Surface different sections to different audiences in the same app. | An admin folder visible only when roles = ["admin"] matches. |
| Stage a rollout. | Tag a new section roles = ["beta-testers"]; flip to empty when launching to everyone. |
The roles field is not an alternative to the permission — both must hold: the user needs one of the listed roles and the right to open the leaf.
Folder collapse
A folder with no visible children disappears from the rendered menu. This means:
- A folder that wraps three leaves, all gated by
roles = ["admin"], vanishes entirely for a non-admin user — they don't see an empty Admin folder. - A folder whose children are all gated by SQL permissions the user lacks similarly vanishes.
This happens at every level — a nested folder structure prunes from the leaves up. The user sees a minimal, useful tree.
The runtime walks the tree once per request, applying the filters and collapsing empties in one pass.
A worked example
A menu with mixed visibility:
[menus.crm]
label = "CRM"
# Top-level — always visible
[[menus.crm.items]]
id = "pipeline"
label = "Pipeline"
icon = "briefcase"
[[menus.crm.items]]
id = "pipeline.customers"
parent = "pipeline"
label = "Customers"
type = "query"
target = "customers_get"
# implicit: sql:crm:customers_get
[[menus.crm.items]]
id = "pipeline.deals"
parent = "pipeline"
label = "Deals"
type = "query"
target = "deals_get"
# implicit: sql:crm:deals_get
[[menus.crm.items]]
id = "reports"
label = "Reports"
icon = "chart-bar"
[[menus.crm.items]]
id = "reports.monthly"
parent = "reports"
label = "Monthly revenue"
type = "query"
target = "monthly_revenue_get"
roles = ["manager", "admin"]
[[menus.crm.items]]
id = "reports.cohort"
parent = "reports"
label = "Cohort analysis"
type = "query"
target = "cohort_get"
roles = ["analyst", "admin"]
[[menus.crm.items]]
id = "admin"
label = "Admin"
icon = "shield"
[[menus.crm.items]]
id = "admin.config"
parent = "admin"
label = "Config"
type = "query"
target = "config_get"
roles = ["admin"]
What different users see:
| User | Roles | Has sql:crm:* | Visible menu |
|---|---|---|---|
| Alice (user) | ["user"] | customers_get, deals_get only | Pipeline → Customers, Deals. (no Reports, no Admin) |
| Bob (manager) | ["manager"] | every sql:crm:* | Pipeline → Customers, Deals · Reports → Monthly revenue. (no Cohort: not analyst; no Admin) |
| Carol (admin) | ["admin"] | every sql:crm:* | Pipeline → Customers, Deals · Reports → Monthly revenue, Cohort · Admin → Config. |
| Dave (manager + analyst) | ["manager", "analyst"] | every sql:crm:* | Pipeline → Customers, Deals · Reports → Monthly revenue, Cohort. (no Admin) |
| Eve (no permission) | ["guest"] | none | Empty tree — the app is left out of the picker. |
Note how the Reports folder doesn't appear for Alice (her roles don't intersect any child); the Admin folder doesn't appear for Alice / Bob / Dave; the app is left out of Eve's application picker.
Permission shapes
Liberty's permission strings follow a simple pattern:
| String | Grants |
|---|---|
sql:<connector>:<query> | Run that specific SQL query. |
sql:<connector>:* | Run every query on that connector. |
sql:* | Run every query on every connector. |
api:<connector>:<endpoint> | Call that specific API endpoint. |
api:<connector>:* | Call every endpoint on that connector. |
menu:<app>:<id> | That menu folder or entry in read: shown, with what its screens read. A !menu:… deny hides it. |
edit:<app>:<id> | On top of menu:, read and change: what its screens write and run, its jobs included. |
menu:<app>:*, edit:<app>:* | The whole application, in read or in read and change; a choice on a folder or an entry wins over it. |
* | Everything. |
A superuser is a flag on the user, not a permission: it passes every check.
For menu pruning, the relevant permissions are menu: (the folder or entry granted) and sql: / api: (matching the leaf's target). A role granting menu:crm:* or sql:crm:* opens every screen and query leaf on the crm app.
The usual way to grant an application is the menu grant, set in the role editor: a folder, or the whole application, in Read or in Read and change. The server works out the sql: / api: permissions the screens under it need — read query, dropdown lists, record-form tabs, and for change the writes, the actions' targets and the jobs —, so a role stays a few lines and follows its folders when screens are added. sql:<c>:* remains possible for a role that should run every query of a connector, menus or not; the roles filter on individual items handles the exceptions.
How the pruning runs
GET /api/menus fires when the user opens the app. The runtime:
- Loads the user's roles + permissions from the JWT.
- Walks the tree depth-first.
- For each leaf:
- Check the implicit permission. If the user lacks it, the leaf is dropped.
- Check the
rolesfilter. If the list is non-empty and the user has none of them, the leaf is dropped.
- For each folder: drop it if no descendants survived.
- Return the pruned tree.
The pruning is per-request — it picks up permission changes the moment the user re-authenticates. No restart needed.
Dashboards, pages and links
An entry is shown for what the user may open through it:
| Leaf type | Shown when |
|---|---|
screen | The user holds the sql: permission of the screen's read query. |
query, endpoint | The user holds sql:<connector>:<target> / api:<connector>:<target>. |
dashboard | The user can read at least one of its data widgets, or holds dashboard:<id>. A dashboard of texts and links only is shown to everyone. |
page | Data Explorer, or an analysis or dashboard of it: the user may use the model (explorer:<app>:<model>). A page an application ships (/app/<app>/<page>): page:<app>:<page>. Nomaflow pages: nomaflow:view. Tests pages: tests:view. Any other page: everyone. |
job | The user may run the job: the entry or its folder in Read and change, or job:<id>. Read alone does not show it. |
url | Everyone. |
On every type but job, the entry or its folder in Read shows the entry; on every type, a menu: deny hides it, and the roles filter applies first.
The licence comes before all of this: the menu of an application the licence does not cover is not shown, nor an entry of another menu that opens one of its pages — see What a key covers. An entry that opens a page and names Screens the page works through gives those screens' read — and their change with Read and change — see A page an application ships.
Which applications a user sees. An application that has a menu and is shown in the switcher is listed for a user only when at least one of its entries is theirs through a permission. The entries open to everyone — an external address, an open page, a dashboard of texts — do not list an application by themselves. A superuser, or a role holding *, sees every application.
To check a role, open it in Liberty Next → Administer → Access: the eye of each entry and the count of each application (sales · 4 of 6 shown) follow this rule. The AI assistant names the applications by the same rule.
Common pitfalls
| Mistake | Symptom | Fix |
|---|---|---|
roles = ["Manager"] (capitalised). | Users with the lowercase manager role don't see the item. | Roles are case-sensitive. Use the exact spelling from the roles config. |
Granting sql:crm:* to a role but the screen still doesn't appear. | The user's session was issued before the grant. | Sign out / sign back in to refresh the JWT. |
roles = [] (explicit empty list). | Equivalent to leaving the field blank — implicit permission alone. | If you meant "only admins", use roles = ["admin"]. |
| Folder visible despite all leaves being hidden. | The pruning ran on stale data (rare race condition during a hot reload). | Refresh the page. |
| A user does not see a dashboard entry. | The role reads none of the dashboard's data widgets. | Set the entry or its folder to Read, or grant dashboard:<id>. |
| A user does not see a job entry. | The entry or its folder is in Read: running a job needs Read and change. | Set the entry or its folder to Read and change, or grant job:<id>. |
| A user does not see an application in the switcher. | Its only entries open to that user need no permission (links, open pages). | Grant a permission on one of its screens, dashboards or Data Explorer models. |
| Menu shows nothing for a brand-new user. | The user's role grants no folder or entry of this app, and no sql: / api: permission on it. | Set a folder, or the whole application, to Read in the role. |
What's next
- Translations and icons — per-language labels and icons.
- Build the tree — the editor surface.
- Concepts → Authentication → Roles and permissions — the deeper reference behind the permission strings.