Skip to content

Commit

Permalink
!!! TASK: Adjust workspace module privilege names
Browse files Browse the repository at this point in the history
The change includes the code migration for existing projects
  • Loading branch information
Sebobo committed Jun 3, 2024
1 parent 2c1b78e commit 4d9ed13
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Neos.Workspace.Ui/Configuration/Policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,58 @@ privilegeTargets:

'Neos\Flow\Security\Authorization\Privilege\Method\MethodPrivilege':

'Neos.Neos:Backend.PublishAllToLiveWorkspace':
'Neos.Workspace.Ui:Backend.PublishAllToLiveWorkspace':
label: Allowed to publish to the live workspace
matcher: 'method(Neos\Workspace\Ui\Controller\WorkspaceController->publishWorkspaceAction(workspace.baseWorkspace.name === "live"))'

'Neos.Neos:Backend.CreateWorkspaces':
'Neos.Workspace.Ui:Backend.CreateWorkspaces':
label: Allowed to create a workspace
matcher: 'method(Neos\Workspace\Ui\Controller\WorkspaceController->(create|new)Action())'

'Neos.Neos:Backend.Module.Management.Workspaces.ManageOwnWorkspaces':
'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageOwnWorkspaces':
label: Allowed to manage own workspaces
matcher: 'method(Neos\Workspace\Ui\Controller\WorkspaceController->(publishWorkspace|discardWorkspace|edit|update|delete)Action(workspace.owner === current.userInformation.backendUser))'

'Neos.Neos:Backend.Module.Management.Workspaces.ManageInternalWorkspaces':
'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageInternalWorkspaces':
label: Manage internal workspaces
matcher: 'method(Neos\Workspace\Ui\Controller\WorkspaceController->(publishWorkspace|discardWorkspace|edit|update|delete)Action(workspace.owner === null))'

'Neos.Neos:Backend.Module.Management.Workspaces.ManageAllPrivateWorkspaces':
'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageAllPrivateWorkspaces':
label: Manage all private workspaces
matcher: 'method(Neos\Workspace\Ui\Controller\WorkspaceController->(publishWorkspace|discardWorkspace|edit|update|delete)Action()) && evaluate(this.workspace.owner !== current.userInformation.backendUser, this.workspace.personalWorkspace === false)'

'Neos\Neos\Security\Authorization\Privilege\ModulePrivilege':
'Neos.Neos:Backend.Module.Management.Workspaces':
'Neos.Workspace.Ui:Backend.Module.Management.Workspaces':
label: General access to the workspace module
matcher: 'management/workspaces'

roles:
'Neos.Neos:LivePublisher':
privileges:
-
privilegeTarget: 'Neos.Neos:Backend.PublishAllToLiveWorkspace'
privilegeTarget: 'Neos.Workspace.Ui:Backend.PublishAllToLiveWorkspace'
permission: GRANT

'Neos.Neos:AbstractEditor':
privileges:
-
privilegeTarget: 'Neos.Neos:Backend.CreateWorkspaces'
privilegeTarget: 'Neos.Workspace.Ui:Backend.CreateWorkspaces'
permission: GRANT

-
privilegeTarget: 'Neos.Neos:Backend.Module.Management.Workspaces.ManageOwnWorkspaces'
privilegeTarget: 'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageOwnWorkspaces'
permission: GRANT

-
privilegeTarget: 'Neos.Neos:Backend.Module.Management.Workspaces'
privilegeTarget: 'Neos.Workspace.Ui:Backend.Module.Management.Workspaces'
permission: GRANT

'Neos.Neos:Administrator':
privileges:
-
privilegeTarget: 'Neos.Neos:Backend.Module.Management.Workspaces.ManageInternalWorkspaces'
privilegeTarget: 'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageInternalWorkspaces'
permission: GRANT

-
privilegeTarget: 'Neos.Neos:Backend.Module.Management.Workspaces.ManageAllPrivateWorkspaces'
privilegeTarget: 'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageAllPrivateWorkspaces'
permission: GRANT
59 changes: 59 additions & 0 deletions Neos.Workspace.Ui/Migrations/Code/Version20240603134000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Neos\Flow\Core\Migrations;

/*
* This file is part of the Neos.Workspace.Ui package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

/**
* Update privilege names related to the workspace module in custom roles
*/
class Version20240603134000 extends AbstractMigration
{

public function getIdentifier(): string
{
return 'Neos.Workspace.Ui-20240603134000';
}

public function up(): void
{
$this->searchAndReplace(
'Neos.Neos:Backend.PublishAllToLiveWorkspace',
'Neos.Workspace.Ui:Backend.PublishAllToLiveWorkspace',
['yaml']
);
$this->searchAndReplace(
'Neos.Neos:Backend.CreateWorkspaces',
'Neos.Workspace.Ui:Backend.CreateWorkspaces',
['yaml']
);
$this->searchAndReplace(
'Neos.Neos:Backend.Module.Management.Workspaces.ManageOwnWorkspaces',
'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageOwnWorkspaces',
['yaml']
);
$this->searchAndReplace(
'Neos.Neos:Backend.Module.Management.Workspaces.ManageInternalWorkspaces',
'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageInternalWorkspaces',
['yaml']
);
$this->searchAndReplace(
'Neos.Neos:Backend.Module.Management.Workspaces.ManageAllPrivateWorkspaces',
'Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageAllPrivateWorkspaces',
['yaml']
);
$this->searchAndReplace(
'Neos.Neos:Backend.Module.Management.Workspaces',
'Neos.Workspace.Ui:Backend.Module.Management.Workspace',
['yaml']
);
}
}

0 comments on commit 4d9ed13

Please sign in to comment.