Server API: roles
Copy as MarkdownThese routes are on the server API, port 21114 (21121 in Docker). They take an API key in X-API-Key or a sign-in token; see The HTTP API.
The roles, their built-in permissions, the stored overrides and the console sections access rules can name.
List the console sections, the permissions and the built-in permissions of each role.
Any signed-in caller may read it.
On the server API, port 21114.
200: Done (application/json)
| Field | Type | What it is |
|---|---|---|
sections |
array of object | |
sections[].key |
string | |
sections[].label |
string | |
sections[].group |
string | |
sections[].read_permission |
string | |
sections[].write_permission |
string | |
groups |
array of object | |
groups[].key |
string | |
groups[].label |
string | |
permissions |
array of string | Sorted |
role_defaults |
object | Per role, its built-in permissions |
source |
"go" |
| Error | When |
|---|---|
| 401 | No credential, or one that is not valid |
List the permissions changed from the built-in roles.
On the server API, port 21114. Needs server.config.
| Parameter | In | Type | What it is |
|---|---|---|---|
role |
query | string, one of super_admin, admin, global_admin, server_admin, operator, viewer, guest_issuer, pro |
Only this role's overrides |
200: Done (application/json)
| Field | Type |
|---|---|
overrides |
array of object |
overrides[].role |
string |
overrides[].permission |
string |
overrides[].granted |
boolean |
| Error | When |
|---|---|
| 401 | No credential, or one that is not valid |
| 403 | The credential's role lacks the permission |
Give a role a permission or take one away.
Super admins only. The super admin roles cannot be changed. A body without granted takes the permission away.
On the server API, port 21114. Needs the sign-in token of a person; API keys are refused. Needs server.config.
Request body, application/json:
| Field | Type | Required | What it is |
|---|---|---|---|
role |
string, one of super_admin, admin, global_admin, server_admin, operator, viewer, guest_issuer, pro |
yes | |
permission |
string | yes | Like device.edit |
granted |
boolean |
200: Done (application/json)
| Field | Type |
|---|---|
status |
"ok" |
| Error | When |
|---|---|
| 400 | The request is not valid |
| 401 | No credential, or one that is not valid |
| 403 | An API key, or not a super admin |
Undo a change to a role: back to its built-in permission.
Super admins only.
On the server API, port 21114. Needs the sign-in token of a person; API keys are refused. Needs server.config.
| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
role |
path | string, one of super_admin, admin, global_admin, server_admin, operator, viewer, guest_issuer, pro |
yes | The role |
permission |
path | string | yes | Like device.edit |
200: Done (application/json)
| Field | Type |
|---|---|
status |
"ok" |
| Error | When |
|---|---|
| 400 | The request is not valid |
| 401 | No credential, or one that is not valid |
| 403 | An API key, or not a super admin |
List the roles with their levels and built-in permissions.
Overrides are not applied: GET /api/roles/{role}/permissions has the permissions in effect.
On the server API, port 21114. Needs user.view.
200: Done (application/json)
| Field | Type |
|---|---|
roles |
array of object |
roles[].name |
string |
roles[].level |
integer |
roles[].is_super_admin |
boolean |
roles[].is_server_level |
boolean |
roles[].permissions |
array of string |
all_permissions |
array of string |
| Error | When |
|---|---|
| 401 | No credential, or one that is not valid |
| 403 | The credential's role lacks the permission |
Show the permissions a role has now, overrides included.
On the server API, port 21114. Needs user.view.
| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
role |
path | string, one of super_admin, admin, global_admin, server_admin, operator, viewer, guest_issuer, pro |
yes | The role |
200: Done (application/json)
| Field | Type |
|---|---|
role |
string |
permissions |
array of string |
| Error | When |
|---|---|
| 400 | The request is not valid |
| 401 | No credential, or one that is not valid |
| 403 | The credential's role lacks the permission |