Skip to content

Commit 9103145

Browse files
committed
Adjust to account based authorization
1 parent bbf5366 commit 9103145

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Classes/Fusion/Helper/WorkspaceHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ public function getPersonalWorkspace(ContentRepositoryId $contentRepositoryId):
7171
if ($currentUser === null) {
7272
return [];
7373
}
74+
$authenticatedAccount = $this->securityContext->getAccount();
75+
if ($authenticatedAccount === null) {
76+
return [];
77+
}
7478
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
7579
$personalWorkspace = $this->workspaceService->getPersonalWorkspaceForUser($contentRepositoryId, $currentUser->getId());
76-
$personalWorkspacePermissions = $this->contentRepositoryAuthorizationService->getWorkspacePermissionsForUser($contentRepositoryId, $personalWorkspace->workspaceName, $currentUser);
80+
$personalWorkspacePermissions = $this->contentRepositoryAuthorizationService->getWorkspacePermissionsForAccount($contentRepositoryId, $personalWorkspace->workspaceName, $authenticatedAccount);
7781
$publishableNodes = $this->uiWorkspaceService->getPublishableNodeInfo($personalWorkspace->workspaceName, $contentRepository->id);
7882
return [
7983
'name' => $personalWorkspace->workspaceName->value,

Classes/Infrastructure/Configuration/ConfigurationProvider.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Neos\Flow\Annotations as Flow;
1919
use Neos\Flow\Configuration\ConfigurationManager;
2020
use Neos\Flow\Mvc\Routing\UriBuilder;
21+
use Neos\Flow\Security\Context as SecurityContext;
2122
use Neos\Neos\Domain\Model\WorkspaceClassification;
2223
use Neos\Neos\Domain\Service\WorkspaceService;
2324
use Neos\Neos\Security\Authorization\ContentRepositoryAuthorizationService;
@@ -34,6 +35,9 @@ final class ConfigurationProvider implements ConfigurationProviderInterface
3435
#[Flow\Inject]
3536
protected UserService $userService;
3637

38+
#[Flow\Inject]
39+
protected SecurityContext $securityContext;
40+
3741
#[Flow\Inject]
3842
protected ConfigurationManager $configurationManager;
3943

@@ -97,8 +101,8 @@ public function getConfiguration(
97101
*/
98102
private function getAllowedTargetWorkspaces(ContentRepository $contentRepository): array
99103
{
100-
$backendUser = $this->userService->getBackendUser();
101-
if ($backendUser === null) {
104+
$authenticatedAccount = $this->securityContext->getAccount();
105+
if ($authenticatedAccount === null) {
102106
return [];
103107
}
104108
$result = [];
@@ -107,7 +111,7 @@ private function getAllowedTargetWorkspaces(ContentRepository $contentRepository
107111
if (!in_array($workspaceMetadata->classification, [WorkspaceClassification::ROOT, WorkspaceClassification::SHARED], true)) {
108112
continue;
109113
}
110-
$workspacePermissions = $this->contentRepositoryAuthorizationService->getWorkspacePermissionsForUser($contentRepository->id, $workspace->workspaceName, $backendUser);
114+
$workspacePermissions = $this->contentRepositoryAuthorizationService->getWorkspacePermissionsForAccount($contentRepository->id, $workspace->workspaceName, $authenticatedAccount);
111115
if ($workspacePermissions->read === false) {
112116
continue;
113117
}

0 commit comments

Comments
 (0)