Skip to content

Commit

Permalink
Adjust to account based authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaidelich committed Oct 23, 2024
1 parent bbf5366 commit 9103145
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Classes/Fusion/Helper/WorkspaceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ public function getPersonalWorkspace(ContentRepositoryId $contentRepositoryId):
if ($currentUser === null) {
return [];
}
$authenticatedAccount = $this->securityContext->getAccount();
if ($authenticatedAccount === null) {
return [];
}
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
$personalWorkspace = $this->workspaceService->getPersonalWorkspaceForUser($contentRepositoryId, $currentUser->getId());
$personalWorkspacePermissions = $this->contentRepositoryAuthorizationService->getWorkspacePermissionsForUser($contentRepositoryId, $personalWorkspace->workspaceName, $currentUser);
$personalWorkspacePermissions = $this->contentRepositoryAuthorizationService->getWorkspacePermissionsForAccount($contentRepositoryId, $personalWorkspace->workspaceName, $authenticatedAccount);
$publishableNodes = $this->uiWorkspaceService->getPublishableNodeInfo($personalWorkspace->workspaceName, $contentRepository->id);
return [
'name' => $personalWorkspace->workspaceName->value,
Expand Down
10 changes: 7 additions & 3 deletions Classes/Infrastructure/Configuration/ConfigurationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Configuration\ConfigurationManager;
use Neos\Flow\Mvc\Routing\UriBuilder;
use Neos\Flow\Security\Context as SecurityContext;
use Neos\Neos\Domain\Model\WorkspaceClassification;
use Neos\Neos\Domain\Service\WorkspaceService;
use Neos\Neos\Security\Authorization\ContentRepositoryAuthorizationService;
Expand All @@ -34,6 +35,9 @@ final class ConfigurationProvider implements ConfigurationProviderInterface
#[Flow\Inject]
protected UserService $userService;

#[Flow\Inject]
protected SecurityContext $securityContext;

#[Flow\Inject]
protected ConfigurationManager $configurationManager;

Expand Down Expand Up @@ -97,8 +101,8 @@ public function getConfiguration(
*/
private function getAllowedTargetWorkspaces(ContentRepository $contentRepository): array
{
$backendUser = $this->userService->getBackendUser();
if ($backendUser === null) {
$authenticatedAccount = $this->securityContext->getAccount();
if ($authenticatedAccount === null) {
return [];
}
$result = [];
Expand All @@ -107,7 +111,7 @@ private function getAllowedTargetWorkspaces(ContentRepository $contentRepository
if (!in_array($workspaceMetadata->classification, [WorkspaceClassification::ROOT, WorkspaceClassification::SHARED], true)) {
continue;
}
$workspacePermissions = $this->contentRepositoryAuthorizationService->getWorkspacePermissionsForUser($contentRepository->id, $workspace->workspaceName, $backendUser);
$workspacePermissions = $this->contentRepositoryAuthorizationService->getWorkspacePermissionsForAccount($contentRepository->id, $workspace->workspaceName, $authenticatedAccount);
if ($workspacePermissions->read === false) {
continue;
}
Expand Down

0 comments on commit 9103145

Please sign in to comment.