oat-sa / extension-tao-dac-simple
extension that allows admin to give access to some resources to other people
Installs: 73 741
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 48
Forks: 3
Open Issues: 1
Type:tao-extension
Requires
- oat-sa/extension-tao-backoffice: >=6.0.0
- oat-sa/extension-tao-item: >=11.3
- oat-sa/generis: >=15.32.0
- oat-sa/oatbox-extension-installer: ~1.1||dev-master
- oat-sa/tao-core: >=53.11.4
- dev-master
- v8.0.5
- v8.0.4
- v8.0.3
- v8.0.2
- v8.0.1
- v8.0.0
- v7.10.6
- v7.10.5
- v7.10.4
- v7.10.3
- v7.10.2
- v7.10.1.1
- v7.10.1
- v7.10.0
- v7.9.0
- v7.8.1
- v7.8.0
- v7.7.9
- v7.7.8.1
- v7.7.8
- v7.7.7
- v7.7.6
- v7.7.5
- v7.7.4
- v7.7.3
- v7.7.2
- v7.7.1
- v7.7.0
- v7.6.0
- v7.5.0
- v7.4.1
- v7.4.0
- v7.3.1
- v7.3.0
- v7.2.0.1
- v7.2.0
- v7.1.8
- v7.1.7
- v7.1.6
- v7.1.5
- v7.1.4
- v7.1.3
- v7.1.2
- v7.1.1
- v7.1.0
- v7.0.0
- v6.8.4
- v6.8.3.1
- v6.8.3
- v6.8.2
- v6.8.1
- v6.7.2
- v6.6.1
- v6.5.1
- v6.4.0
- v6.1.2
- v6.1.1
- v6.1.0
- v6.0.1
- v5.1.2
- v5.1.1
- v5.1.0.1
- v5.1.0
- v5.0.1
- v5.0.0
- v4.1.0
- v4.0.0
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.0.0
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.3
- v2.0.1
- v2.0.0
- v1.5.0
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.0.2
- v1.0.1
- 1.0.1-beta
- dev-l10n_develop
- dev-develop
- dev-feature/sonarqube-integration
- dev-fix/update-autoRelease-action-with-bot-user
- dev-backport/adf-1541/v7.10.1.1
- dev-release-7.7.8.1
- dev-hotfix/AUT-2995/add-brazilian-portuguese-language
- dev-feat/ADF-1320-split-permission-update-into-subtasks
- dev-fix/AUT-2851/fix_unittest_php81
- dev-fix/AUT-2801/fix_unittest_for_PHP81
- dev-fix/AUT-2619-backport
- dev-release-7.7.2
- dev-fix/AUT-1825/failed_release
- dev-feature/AUT-1825/update_nb-no
- dev-feature/ADF-654-recursive-acl-gets-stuck
- dev-backport-release-2021-08-lts
- dev-release-2021-08-lts
- dev-feature/TAO-10203-advanced-search
- dev-fix/ADF-12/code_integration
- dev-release/6.8.3.1
- dev-fix/UNO-532/no-results-found-list-mode
- dev-release/5.1.2
- dev-release/6.0.1
- dev-release/6.8.2
- dev-release/6.8.1
- dev-release/6.7.2
- dev-release/6.6.1
- dev-release/6.5.1
- dev-release/6.4.0
- dev-release/6.1.2
- dev-release/6.1.1
- dev-release/6.1.0
- dev-backport/5.1.1/update-translations
- dev-fix/UNO-186/taskqueue_integration
- dev-fix/NCC-152/AssignmentsReportKeepsTracksOfAssignment
- dev-feature/UDI-23/recursive-permission-granting-on-child-classes
- dev-TDR-2/fix-code-styling
- dev-release-33/TAO-8153/translation
- dev-feature/TAO-7682-fix-nightly-tests
- dev-feature/TAO-7233/remove-controller-contructor
- dev-fix/action-serialisation
- dev-mpdeploy
- dev-dev-act
- dev-translate
- dev-read-write
- dev-OAT-55-migrate
- dev-quality
This package is auto-updated.
Last update: 2024-11-03 14:05:35 UTC
README
Simple Data Access Control allows the restriction of which user can access which resources, in the way compatible with Advanced Search.
Access Privileges are granted either to users directly or to roles, applying to all users who have that specific role.
Privileges are given per resource, so that in order to remove the write access to all items within a class, the new access rights need to be applied recursively to all resources by checking "recursive" before saving the changes.
Privileges are additive, meaning that if:
- Role A has write and read access to Item 1
- User X has read access to Item 1
- And User X has the Role A
Then User X he will have read and write access to Item 1
How to enable ACL management
In order to see the Access control
button on the backoffice panel a few changes are necessary.
Enable this in the actions
Change the actions/structures.xml
file by adding the attribute allowClassActions="true"
in the actions
node:
<?xml version="1.0" encoding="utf-8"?> <structures> <structure> <sections> <section> <trees><!-- Something here --></trees> <actions allowClassActions="true"> <action><!-- Something here --></action> </actions> </section> </sections> </structure> </structures>
Enable ACL in an endpoint
Add the annotation requiresRight
with proper field
and grant level
to check permissions:
class MyController extends tao_actions_SaSModule { /** * @requiresRight id READ */ public function editInstance() { //... } }
Checking ACL internally (without annotations) in the endpoint
If extending tao_actions_RdfController
we can use the method hasWriteAccess
:
class MyController extends tao_actions_SaSModule { public function editItem() { $item = $this->getCurrentInstance(); if ($this->hasWriteAccess($item->getUri())) { // Do something } } }
Or we can use the DataAccessControl
implementation directly:
$user = $this->getSession()->getUser(); $item = $this->getCurrentInstance(); $dataAccessControl = new \oat\tao\model\accessControl\data\DataAccessControl(); $canWrite = $dataAccessControl->hasPrivileges($user, [$item->getUri() => 'WRITE']); $canRead = $dataAccessControl->hasPrivileges($user, [$item->getUri() => 'READ']);
Permissions save strategies
Currently, we have the following saving/propagating permissions strategies:
- SyncPermissionsStrategy (Default): Overwrites existent permissions with the new ones provided by the user.
- SavePermissionsStrategy: Merges existing permissions with the new ones provided by the user.
IMPORTANT: Saving with recursive option is very dangerous, cause will override permissions for all subclasses and resources.
The permission strategy is configured here config/taoDacSimple/PermissionsService.conf.php
. Example:
<?php return new oat\taoDacSimple\model\PermissionsServiceFactory( [ 'save_strategy' => 'oat\\taoDacSimple\\model\\SyncPermissionsStrategy', 'recursive_by_default' => false ] );