JoomGalleryfriends / JG4-dev

Development repository for JoomGallery v4.x
GNU General Public License v3.0
10 stars 6 forks source link

Access service v2 #113

Closed Elfangor93 closed 1 year ago

Elfangor93 commented 1 year ago

What is this service for

This is a redo of PR #104 since the old PR is somehow messed up and not working anymore...

The Access service will be used to extend the default ACL logic of Joomla core in order to allow checks against inown and own access rules. Inown and own access rules are used in JoomGallery to manage ACL exceptions. For example, a user may perform a certain task within an asset of which he is the creator (owner), even if this task is generally forbidden for him.

How to use this service

You can load the service anywhere in Joomla by doing

$component = Factory::getApplication()->bootComponent('com_joomgallery');  // boot JoomGallery component
$component->createAccess();   // instantiate the service
$acl = $component->getAccess();   // load the service into your scope
$acl->setUser(<userID>); // perform checks against a specified user. If no user is set the current user will be used.
$res = $acl->checkACL(<action>, <asset>, <ID>); // check if the user is permitted to perform <action> on <asset> with the ID <ID>

The following actions are available: add, admin, delete, edit, editstate, manage

The following assets are available: image, category, tag, config

How to test the service

Make sure "Debug System" is "Yes" in Joomla Global configuration. Open the file /administrator/com_joomgallery/src/View/Faulties/HtmlView.php and insert the following code on line 62 after throw new \Exception(implode("\n", $errors)); }

Different test instructions see comments below...

szepty-ziemi commented 1 year ago

There is js error when changing permissions in image:

obraz

When changing permission setting spin image is shown but spins forever. Settings are changed when clicking SAVE image button.

ENV: https://prnt.sc/NXBHI6bFSnBO

szepty-ziemi commented 1 year ago

Global settings

Category settings:

Image settings

RESULT: OK

Elfangor93 commented 1 year ago

There is a warning: It seems it shows when root category is called.

True. Should be fixed now...

Elfangor93 commented 1 year ago

There is js error when changing permissions in image

I will not fix this issue here since it is not related to the access service and it also does not affect the access control from working. Its just a GUI error. I created an issue for that: #124

Elfangor93 commented 1 year ago

@szepty-ziemi Do you think we can merge now this PR?

szepty-ziemi commented 1 year ago

There is a warning: It seems it shows when root category is called.

True. Should be fixed now...

Checked, I confirm it's fixed.

If your last commits do not touch previous changes then regression testing is not needed. If so - we're good to go ;)