Repository navigation
Export and Import
From rbac 1.3.0, roles can be written to a file and read back, on the same engine or another one. Only users holding the admin role can export or import.
Both buttons, Export Roles and Import Roles, are on the Role-Based Access Control settings tab, in the desktop Administrator and the web Administrator, and only for users holding the admin role.
The Export Roles dialog lists the roles on this engine, all ticked, with their descriptions and the counts of their permissions and channels. Select a role to see its permissions and its channels (name and id) below. Untick the roles you don't want, then click Export and choose where to save the file.
The file holds each role's name, description, permissions and channel restrictions, with each channel's id and name. It is plain XML, even when the engine encrypts its own exports, so another engine can read it. The admin role is never exported. Neither are user assignments: a role comes in with no users.
Channel restrictions are included. When importing, you can choose not to apply them.
Pick the file. The Import Roles dialog previews the import before anything is written: a table of the roles in the import on top, and for the selected role, two tables below.
The roles table has one row per role in the import:
- Import: the tick box. New roles start ticked, overwrites start unticked.
- Action: New (no role with that name on this engine), Overwrite (a role with that name exists and differs; it keeps its name and its users), Unchanged (exists and matches), or Skipped (the admin role's name, which an import never changes).
- Description currently and Description after import.
- Permissions and Channels: counts, as "2 → 1" for a change, "every" for a role that sees every channel, "none" for a role restricted to no channels.
- Notes: what the import does to the role's channels, and how many of the import's channels and permissions this engine lacks. The same text is in the REST answer.
Click a row to see the role's details:
- Permissions: Permission | Currently | After import | Note. "Currently" means this role has the permission on this engine; "After import" means this role will have the permission if imported. A permission this engine doesn't offer is left out and noted.
- Channels: Channel | Id on this engine | Currently | After import | Match | Name in import | Id in import. "Currently" means this role is restricted to the channel on this engine; "After import" means this role will be restricted to the channel if imported. Match says how the import's channel was found on this engine: by id; by id, renamed on this engine (the channel kept its id but has another name now; the import's name is in its own column); by name or by name, not used (see below); not on this engine (the import names a channel this engine doesn't have); not in the import (this role has the channel on this engine and the import doesn't name it); or deleted on this engine (a channel this role is still restricted to here that no longer exists, until the next startup removes the reference). Every column sorts on a header click.
Tick the roles to import and click Import. The picked roles are written together: all of them, or none if anything fails. If a role the import names changed on this engine since the preview, the import stops and asks you to preview again.
A role is either unrestricted (it sees every channel) or restricted to a list of channels, and a restricted role whose list is empty sees no channel at all. That is the state a role is left in when every channel it was restricted to has been deleted (rbac removes a restriction the moment its channel is deleted), and the state a role is imported in when none of its channels exist on this engine.
Apply channel restrictions from the import (ticked to start): each role gets the channels the import lists, matched by channel id. A role none of whose channels exist on this engine is imported restricted to no channel, with a note saying so; it sees no channel until an administrator sets channels for it, and it starts ticked like any new role.
Also match channels by name when the id isn't found (unticked to start): for a channel whose id isn't on this engine, use the channel on this engine with the same name, if exactly one has it. While the box is unticked, a line under it says how many channels in the import match a channel on this engine by name only, and the channels table marks each of them "by name, not used"; tick the box and they become "by name" and count. This is for engines whose channels were built separately, such as a test engine and a production engine.
With Apply channel restrictions from the import unticked, roles that already exist on this engine keep their current channels and new roles are restricted to no channel until an administrator sets channels for them; the channels table is replaced by a line saying so.
Role names are compared exactly as typed: "Lab" and "LAB" are two roles. Derby, PostgreSQL and Oracle can hold both. MySQL and SQL Server compare names ignoring case by default, and MySQL ignores accents too, so there only one of the two can exist:
- A role in the file matches an existing role whose name differs only in case, and an overwrite keeps the existing name.
- A file that holds both "Lab" and "LAB" as new roles is refused with "Rename one of them in the file.", and nothing is written. The rest of the file can still be imported without one of them.
- Since 1.4.0 a file is refused, and nothing is written, if a role it would create has a name with a control character, a line break, a bidirectional control character or a character XML can't carry. It is also refused if a description it would add or change has a control character other than a tab or a line break, or a character XML can't carry. The editors apply the same rules to new and changed names and descriptions. Existing names and descriptions are left alone.
The engine's own backup (Backup Config) doesn't include rbac's roles or role assignments, and restoring one leaves rbac's roles as they are. It doesn't include the engine's users either. To move to a new engine:
- Export the roles on the old engine.
- Install rbac on the new engine and restart it.
- Restore the engine's backup. Channels keep their ids, so the roles file matches them by id.
- Create the users.
- Import the roles file.
- Assign each user a role.
The file format, what an import refuses, and the REST calls behind export and import are in docs/role-export-format.md.