Commit 6af71d98 authored by Jörg Richter's avatar Jörg Richter

Consolidate Access Control migrations, pt. 3

parent 68019961
Pipeline #6612 passed with stages
in 3 minutes and 11 seconds
......@@ -11,6 +11,7 @@ import systems.dmx.core.service.Migration;
/**
* Create "System" and "Administration" workspaces.
* Set owner of "System", "Administration", and "DMX" workspaces.
* <p>
* Part of DMX 5.0
* Runs ALWAYS
......@@ -32,6 +33,12 @@ public class Migration2 extends Migration {
@Override
public void run() {
// Note 1: at migration running time our plugin listeners are not yet registered (furthermore there is no user
// logged in). So we set the workspace owner manually here.
// Note 2: we don't set a particular creator/modifier here as we don't want suggest the workspaces have been
// created by the "admin" user. Instead the creator/modifier of the workspaces remain undefined as the
// workspaces are actually created by the system itself.
//
// "System"
Topic systemWorkspace = wsService.createWorkspace(
AccessControlService.SYSTEM_WORKSPACE_NAME,
......@@ -48,10 +55,8 @@ public class Migration2 extends Migration {
);
acService.setWorkspaceOwner(adminWorkspace, AccessControlService.ADMIN_USERNAME);
//
// Note 1: at migration running time our plugin listeners are not yet registered (furthermore there is no user
// logged in). So we set the workspace owner manually here.
// Note 2: we don't set a particular creator/modifier here as we don't want suggest the workspaces have been
// created by the "admin" user. Instead the creator/modifier of the workspaces remain undefined as the
// workspaces are actually created by the system itself.
// "DMX"
acService.setWorkspaceOwner(wsService.getWorkspace(WorkspacesService.DMX_WORKSPACE_URI),
AccessControlService.ADMIN_USERNAME);
}
}
package systems.dmx.accesscontrol.migrations;
import systems.dmx.accesscontrol.AccessControlService;
import systems.dmx.workspaces.WorkspacesService;
import systems.dmx.core.service.Inject;
import systems.dmx.core.service.Migration;
import systems.dmx.core.service.accesscontrol.Credentials;
/**
* Set "admin" as the owner of the "DMX" workspace.
* Create "admin" user account.
* <p>
* Part of DMX 5.0
* Runs ALWAYS
* <p>
* Note: both must exist already, the "Login enabled" config topic type (created in migration 1), and the
* "Administration" workspace (created in migration 2).
*/
public class Migration3 extends Migration {
......@@ -21,17 +24,13 @@ public class Migration3 extends Migration {
@Inject
private AccessControlService acService;
@Inject
private WorkspacesService wsService;
// -------------------------------------------------------------------------------------------------- Public Methods
@Override
public void run() {
acService.setWorkspaceOwner(wsService.getWorkspace(WorkspacesService.DMX_WORKSPACE_URI),
AccessControlService.ADMIN_USERNAME);
// Note: we don't set a particular creator/modifier here as we don't want suggest that the DMX workspace has
// been created by the "admin" user. Instead the creator/modifier of the DMX workspace remain undefined as the
// DMX workspace is actually created by the system itself.
acService.createUserAccount(new Credentials(
AccessControlService.ADMIN_USERNAME,
AccessControlService.ADMIN_INITIAL_PASSWORD
));
}
}
package systems.dmx.accesscontrol.migrations;
import systems.dmx.accesscontrol.AccessControlService;
import systems.dmx.core.service.Inject;
import systems.dmx.core.service.Migration;
import systems.dmx.core.service.accesscontrol.Credentials;
/**
* Create "admin" user account.
* <p>
* Part of DMX 5.0
* Runs ALWAYS
* <p>
* Note: both must exist already, the "Login enabled" config topic type (created in migration 1), and the
* "Administration" workspace (created in migration 2).
*/
public class Migration4 extends Migration {
// ---------------------------------------------------------------------------------------------- Instance Variables
@Inject
private AccessControlService acService;
// -------------------------------------------------------------------------------------------------- Public Methods
@Override
public void run() {
acService.createUserAccount(new Credentials(
AccessControlService.ADMIN_USERNAME,
AccessControlService.ADMIN_INITIAL_PASSWORD
));
}
}
dmx.plugin.model_version = 4
dmx.plugin.model_version = 3
dmx.plugin.activate_after = systems.dmx.webclient
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment