Rights and roles #
A migration changes a collection's model, closes its writes, and its archive holds old values. This page lists the rights each action needs, and gives two roles ready to paste: one to run migrations, one to follow them.
Rights per action #
| Action | Who should get it |
|---|---|
start | Administrators only: it changes a collection's model and closes its writes |
purge | Administrators only: it deletes the old values for good |
status, failures | Whoever follows migrations (status also gives the realtime progress) |
The plugin's rights are not enough on their own: the caller also needs, on the collection the migration targets, the right the same operation takes through Kuzzle's API. Otherwise the action is refused with plugin.mapping-migration.forbidden (403), which names the missing right.
| Action | Right also needed on the target collection |
|---|---|
start (dry run) | collection:getMapping |
start with apply | collection:update |
failures | document:search (failed documents show ids and values) |
status | none; document:search to see reindex.failures (otherwise null, the rest is shown) |
purge | collection:update |
status shows every migration (index, collection, counts, phase), without document content, to whoever has its right. Calls made by the application's own code (embedded SDK, no user) are not checked. A role change applies at once, without logging in again.
The progress room only takes the plugin's own messages: a client publishing on it (realtime:publish on plugin-mapping-migration) is refused (progress_publish, 403), and one subscribing to it directly (progress_subscription, 403) is pointed to status with subscribe: true.
Roles #
mapping-migration-admin: plans, applies and purges migrations, and follows them.
{
"controllers": {
"mapping-migration/migration": {
"actions": { "start": true, "status": true, "failures": true, "purge": true }
},
"collection": {
"actions": { "getMapping": true, "update": true }
},
"document": {
"actions": { "search": true }
}
}
}mapping-migration-viewer: follows migrations and reads their failed documents.
{
"controllers": {
"mapping-migration/migration": {
"actions": { "status": true, "failures": true }
},
"document": {
"actions": { "search": true }
}
}
}Drop document:search from the viewer role to show it the jobs and counts only: failures is then refused, and reindex.failures is null.
Create them with the SDK (sdk.security.createOrReplaceRole("mapping-migration-admin", <role>)), Kourou, the Admin Console, or security:createOrReplaceRole over HTTP:
curl -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
"http://localhost:7512/roles/mapping-migration-viewer" \
-d '{ "controllers": { "mapping-migration/migration": { "actions": { "status": true, "failures": true } }, "document": { "actions": { "search": true } } } }'Restricting to some collections #
A role grants actions; a profile can restrict a role to some indexes and collections with restrictedTo. The plugin checks the collection rights above against the collection a migration targets, so a restricted profile can only migrate, read the failures of, or purge the migrations of its collections:
{
"policies": [
{
"roleId": "mapping-migration-admin",
"restrictedTo": [{ "index": "iot", "collections": ["sensors"] }]
}
]
}status is not tied to a collection: whoever has its right sees the jobs and archives of every collection (no document content), whatever the profile's restrictions.