Doku durchsuchen
Menü
Geändert am Auf GitHub bearbeiten

Konsole: roles

Als Markdown kopieren

Diese Routen liegen auf der Konsole, Port 3375. Sie nehmen ein API-Token als Authorization: Bearer ndt_...; siehe API-Tokens. Die Beschreibungen stehen auf Englisch, wie in der OpenAPI-Beschreibung.

Roles and their permissions.

GET /api/panel/role-permissions

List the permissions changed from the built-in roles.

Needs server.config. neodesk roles overrides calls it.

Parameter In Type What it is
role query string Only this role's overrides

200: Done (application/json)

Field Type Required
success true yes
data object yes
data.overrides array of object
data.overrides[].role string
data.overrides[].permission string
data.overrides[].granted boolean
Error When
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 The account or the token may not do this, or a write from a browser came without a good CSRF token
502 The server API did not answer

POST /api/panel/role-permissions

Give a role a permission or take one away (super admins).

The super admin roles cannot be changed.

Needs the super_admin role, and a full API token. neodesk roles override-set calls it.

Request body, application/json:

Field Type Required What it is
role string yes The role
permission string yes The permission, like device.edit
granted boolean yes true gives it, false takes it away

200: Done (application/json)

Field Type Required
success true yes
data object yes
data.status "ok"
Error When
400 The request is not valid
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 The account or the token may not do this, or a write from a browser came without a good CSRF token
502 The server API did not answer

POST /api/panel/role-permissions/batch

Change several permissions of a role at once (super admins).

Every change is checked before the first is written. When a write fails, the ones before it are put back and the failure is answered. previous, sent back as changes, undoes the batch.

Needs the super_admin role, and a full API token. neodesk roles override-batch calls it.

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
changes array of object yes
changes[].permission string yes
changes[].granted boolean or null yes true gives it, false takes it away, null puts the built-in permission back

200: Done (application/json)

Field Type Required What it is
success true yes
data object yes
data.previous array of object The override stored before each change, null for none
data.previous[].permission string
data.previous[].granted boolean or null
data.permissions array of string or null The role's permissions in effect after
Error When
400 The request is not valid
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 The account or the token may not do this, or a write from a browser came without a good CSRF token
502 The server API did not answer

DELETE /api/panel/role-permissions/{role}/{permission}

Undo a change to a role: back to its built-in permission.

Needs the super_admin role, and a full API token. neodesk roles override-delete calls it. It cannot be undone.

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 The permission, like device.edit

200: Done (application/json)

Field Type Required
success true yes
data object yes
data.status "ok"
Error When
400 The request is not valid
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 The account or the token may not do this, or a write from a browser came without a good CSRF token
502 The server API did not answer

GET /api/panel/roles

List the roles with their levels. roles permissions <role> shows what a role may do.

Needs user.view. neodesk roles list calls it.

200: Done (application/json)

Field Type Required What it is
success true yes
data object yes
data.roles array of object
data.roles[].name string
data.roles[].level integer
data.roles[].is_super_admin boolean
data.roles[].is_server_level boolean
data.roles[].permissions array of string Its built-in permissions; overrides are not applied
data.roles[].fixed object Permissions the code decides for the role, each with the rule's name; overrides of them have no effect
data.all_permissions array of string
data.requires object Per permission, the permissions it needs to be of use, with the reason
Error When
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 The account or the token may not do this, or a write from a browser came without a good CSRF token
502 The server API did not answer

POST /api/panel/roles

Make a custom role, from a list of permissions or as a copy of a role (super admins).

The role gets a stable name, custom_ and up to 30 lower case letters, digits and underscores from the label (custom_helpdesk, then custom_helpdesk_2), which role maps and the API use and which stays when the role is renamed. Give permissions or copy_from, or neither for a role without permissions; copy_from takes the permissions the role has in effect now. Every permission must be one the caller's role has. A server keeps at most 50 custom roles. Logs role_created in the audit log.

Needs the super_admin role, and a full API token. neodesk roles create calls it.

Request body, application/json:

Field Type Required What it is
label string yes The name the console shows, 1 to 60 characters after trimming, without control characters. Not a built-in role's name, and no other custom role's (in any case).; at most 60 characters
description string What the role is for, up to 300 characters after trimming; line breaks are the only control characters it may hold; at most 300 characters
permissions array of string Permission names, like device.view. An older name counts as the ones it stands for; permissions a custom role can't use (creating and deleting accounts) are dropped.
copy_from string A role, built-in or custom, whose permissions the new role starts with, like operator. Not together with permissions.

200: Done (application/json)

Field Type Required
success true yes
data CustomRole yes
Error When
400 The body is no object, the label is missing or not valid, the description is too long, a permission is unknown, permissions and copy_from came together, or copy_from names no role
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 Not a super admin, the token lacks a permission, or the role has or gets a permission the account's role does not have (code permission_not_held)
409 The server has 50 custom roles already (code role_limit), or another role has this name (code role_label_taken)
500 The roles could not be read or written
503 Custom roles are not available (the console runs without the server's database), or the permission check could not be made (code permission_service_unavailable)

PATCH /api/panel/roles/{role}

Rename a custom role or change its description or permissions.

Changes the fields in the body; the others stay, and so does the stable name. permissions replaces all of the role's permissions; when they change, every account with the role is signed out (its console sessions end and its client sign-ins are revoked) and signed_out counts them. The caller must have every permission the role has and gets. Built-in roles can't be changed here. Logs role_changed in the audit log.

Needs the super_admin role, and a full API token. neodesk roles update calls it.

Parameter In Type Required What it is
role path string yes The custom role's stable name, like custom_helpdesk

Request body, application/json:

Field Type What it is
label string The name the console shows, 1 to 60 characters after trimming, without control characters. Not a built-in role's name, and no other custom role's (in any case).; at most 60 characters
description string What the role is for, up to 300 characters after trimming; line breaks are the only control characters it may hold; at most 300 characters
permissions array of string Permission names, like device.view. An older name counts as the ones it stands for; permissions a custom role can't use (creating and deleting accounts) are dropped.

200: Done (application/json)

Field Type Required
success true yes
data CustomRole and object yes
Error When
400 The body is no object or has copy_from, a field is not valid, a permission is unknown, or the path names a built-in role (code role_built_in) or is not a valid role name
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 Not a super admin, the token lacks a permission, or the role has or gets a permission the account's role does not have (code permission_not_held)
404 There is no custom role of that name (Role not found)
409 Another role has this name (code role_label_taken)
500 The roles could not be read or written
503 Custom roles are not available (the console runs without the server's database), or the permission check could not be made (code permission_service_unavailable)

DELETE /api/panel/roles/{role}

Delete a custom role that nothing uses any more.

A role that accounts, API keys or the LDAP, single sign-on, SAML or passkey settings still name is refused with what uses it. Built-in roles can't be deleted. The caller must have every permission the role has. Logs role_deleted in the audit log.

Needs the super_admin role, and a full API token. neodesk roles delete calls it. It cannot be undone.

Parameter In Type Required What it is
role path string yes The custom role's stable name, like custom_helpdesk

200: Done (application/json)

Field Type Required
success true yes
Error When
400 The path names a built-in role (code role_built_in) or is not a valid role name
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 Not a super admin, the token lacks a permission, or the role has or gets a permission the account's role does not have (code permission_not_held)
404 There is no custom role of that name (Role not found)
409 Something still uses the role (code role_in_use); uses says what
500 The roles could not be read or written
503 Custom roles are not available (the console runs without the server's database), or the permission check could not be made (code permission_service_unavailable)

GET /api/panel/roles/{role}/permissions

Show the permissions a role has now, overrides included.

Needs user.view. neodesk roles permissions calls it.

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 Required What it is
success true yes
data object yes
data.role string
data.permissions array of string In the order of the permission list
Error When
400 The request is not valid
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 The account or the token may not do this, or a write from a browser came without a good CSRF token
502 The server API did not answer

GET /api/panel/roles/{role}/uses

Show what still uses a custom role: accounts, API keys and sign-in settings.

A role that something uses can not be deleted.

Needs the super_admin role, and a full API token. neodesk roles uses calls it.

Parameter In Type Required What it is
role path string yes The custom role's stable name, like custom_helpdesk

200: Done (application/json)

Field Type Required
success true yes
data CustomRoleUses yes
Error When
400 The path names a built-in role (code role_built_in) or is not a valid role name
401 No session or API token, or one that is not valid (code session_required or token_invalid)
403 Not a super admin, or the token lacks a permission
404 There is no custom role of that name (Role not found)
500 The roles could not be read or written
503 Custom roles are not available (the console runs without the server's database), or the permission check could not be made (code permission_service_unavailable)

Durchsucht Seiten, Abschnitte, Befehle und Einstellungen.