Hi there
in Document entity, i add a boolean attribute "financialConfidentiality".
I want to control the read access to the "documents" having this attribut set. It will be only accessible to users having the good role
I add a custom ACL checkEntityRead function to control that behaviour.
Here is the code:
When i click on a Document name link, i can see the popup message about the 403 error => meaning that the code is working fine... but, then, the red popup disappear and i have access to the Document detail view... so the ACL doesn't help a lot because the restricted document is displayed
If i completely reload the page ...
i have this given 403 access error (that's ok, that's the expected behaviour) ... and nothing is displayed...
Is there a bug when clicking on the document tree, then clicking on a document name ? I don't know how to avoid to display the detail document content is the ACL is not OK
Thanks for your feedback & support!
I can record my screen if it's not clear :-)
in Document entity, i add a boolean attribute "financialConfidentiality".
I want to control the read access to the "documents" having this attribut set. It will be only accessible to users having the good role
I add a custom ACL checkEntityRead function to control that behaviour.
Here is the code:
PHP Code:
<?php
namespace Espo\Custom\Acl;
use \Espo\Entities\User as EntityUser;
use \Espo\ORM\Entity;
use \Espo\Core\Exceptions\Forbidden;
class Document extends \Espo\Core\Acl\Base {
public function checkEntityRead(EntityUser $user, Entity $entity, $data) {
if ($user->isAdmin()) {
$GLOBALS['log']->info('Document ACL read check => OK (is admin)');
return true;
}
// Document has boolean attribute 'financialConfidentiality' == true
if ($entity->get('financialConfidentiality')) {
$GLOBALS['log']->info('Document ACL read check => need to check roles for the user');
$roleList = [];
foreach ($user->get('roles') as $role)
$roleList[] = $role;
foreach($roleList as $role) {
if ($role->get('name') == 'AdminDocumentFinancier') {
$GLOBALS['log']->info('Document ACL read check => user has role AdminDocumentFinancier => OK');
return true;
}
}
$GLOBALS['log']->info('Document ACL read check => FORBIDDEN ACCESS');
#throw new Forbidden('Acces refusé...');
return false;
}
return true;
}
}
If i completely reload the page ...
i have this given 403 access error (that's ok, that's the expected behaviour) ... and nothing is displayed...
Is there a bug when clicking on the document tree, then clicking on a document name ? I don't know how to avoid to display the detail document content is the ACL is not OK
Thanks for your feedback & support!
I can record my screen if it's not clear :-)
Comment