Skip to content

Commit

Permalink
fix permission propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Jan 17, 2024
1 parent 97dc08d commit 8cca23a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ public function hydrateDocument(PostTransformEvent $event): void
$cUsers[] = $collection->getOwnerId();
}

$cUsers = array_merge($cUsers, $this->permissionManager->getAllowedUsers($collection, PermissionInterface::VIEW));
$cGroups = array_merge($cGroups, $this->permissionManager->getAllowedGroups($collection, PermissionInterface::VIEW));
$pColl = $collection;
while ($pColl) {
$cUsers = array_merge($cUsers, $this->permissionManager->getAllowedUsers($pColl, PermissionInterface::VIEW));
$cGroups = array_merge($cGroups, $this->permissionManager->getAllowedGroups($pColl, PermissionInterface::VIEW));
$pColl = $pColl->getParent();
}
}

$absPath = $collection->getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ public function hydrateDocument(PostTransformEvent $event): void

[$users, $groups] = $this->discoverChildren($collection);

// TODO check impact
// if (!in_array(null, $users, true)) {
// $parent = $collection->getParent();
// while (null !== $parent) {
// $users = array_merge($users, $this->permissionManager->getAllowedUsers($parent, PermissionInterface::VIEW));
// if (in_array(null, $users, true)) {
// break;
// }
//
// $groups = array_merge($groups, $this->permissionManager->getAllowedGroups($parent, PermissionInterface::VIEW));
// $parent = $parent->getParent();
// }
// }
if (!in_array(null, $users, true)) {
$parent = $collection->getParent();
while (null !== $parent) {
$users = array_merge($users, $this->permissionManager->getAllowedUsers($parent, PermissionInterface::VIEW));
if (in_array(null, $users, true)) {
break;
}

$groups = array_merge($groups, $this->permissionManager->getAllowedGroups($parent, PermissionInterface::VIEW));
$parent = $parent->getParent();
}
}

if (in_array(null, $users, true)) {
$users = ['*'];
Expand Down
5 changes: 4 additions & 1 deletion databox/api/src/Entity/Core/RenditionDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
operations: [
new Get(security: 'is_granted("READ", object)'),
new Delete(security: 'is_granted("DELETE", object)'),
new Put(security: 'is_granted("EDIT", object)'),
new Put(
security: 'is_granted("EDIT", object)',
input: RenditionDefinitionInput::class,
),
new Patch(security: 'is_granted("EDIT", object)'),
new GetCollection(),
new Post(securityPostDenormalize: 'is_granted("CREATE", object)'),
Expand Down
3 changes: 3 additions & 0 deletions databox/client/src/api/rendition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export async function putRenditionDefinition(
id: string | undefined,
data: RenditionDefinition
): Promise<RenditionDefinition> {
// @ts-expect-error no workspace
delete data.workspace;

return (await apiClient.put(`${renditionDefinitionNS}/${id}`, data)).data;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Item({
} = usedFormSubmit;

useEffect(() => {
reset(createData(data));
reset(normalizeData(data));
}, [data]);

return (
Expand Down Expand Up @@ -217,12 +217,12 @@ export default function AttributeDefinitionManager({
handleSave={handleSave}
handleDelete={deleteAttributeDefinition}
onSort={onSort}
normalizeData={createData}
normalizeData={normalizeData}
/>
);
}

function createData(data: AttributeDefinition) {
function normalizeData(data: AttributeDefinition) {
return {
...data,
class: data?.class && (data?.class as AttributeClass)['@id'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {RenditionDefinition, Workspace} from '../../../types';
import {RenditionClass, RenditionDefinition, Workspace} from '../../../types';
import {FormGroup, FormLabel, ListItemText, TextField} from '@mui/material';
import FormRow from '../../Form/FormRow';
import DefinitionManager, {
Expand Down Expand Up @@ -34,7 +34,7 @@ function Item({
const {t} = useTranslation();

React.useEffect(() => {
reset(data);
reset(normalizeData(data));
}, [data]);

return (
Expand Down Expand Up @@ -196,6 +196,15 @@ export default function RenditionDefinitionManager({
handleSave={handleSave}
handleDelete={deleteRenditionDefinition}
onSort={onSort}
normalizeData={normalizeData}
/>
);
}


function normalizeData(data: RenditionDefinition) {
return {
...data,
class: data?.class && (data?.class as RenditionClass)['@id'],
};
}

0 comments on commit 8cca23a

Please sign in to comment.