Repository navigation
Manage dashboard access rights per Group and per User - #144
MichaelRodriguesOficial wants to merge 11 commits into
Conversation
Co-authored-by: Stanislas <skita@teclib.com>
Co-authored-by: Stanislas <skita@teclib.com>
Co-authored-by: Stanislas <skita@teclib.com>
Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
Rom1-B
left a comment
There was a problem hiding this comment.
Please correct the CI issues before requesting another review.
- Fix PHP syntax error introduced by the docblock suggestion in itemright.class.php - Render the rights matrix with a Twig template (no more echo) - READ on the group/user is enough to see the tab, UPDATE is required to save - Check rights on the targeted group/user itself, not only the global right - Rename dashboard_uuid column to dashboard_id - Add int type hint and docblock on canCurrentUserViewDashboard() - Remove rights when a group or user is purged - Rebase on GLPI 12 / 1.5.0 and add CHANGELOG entry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115rGXdmY7mffoJzXeFPGhw
|
Thanks for the reviews, and sorry for the noise — the CI failures came from a suggestion I applied This is now fixed and rebased on 1.5.0 / GLPI 12:
Lint, PHP-CS-Fixer, PHPStan, Psalm, Rector, TwigCS and licence headers pass locally against GLPI 12, |
…n item rights form - showForCentral(): resolve user and group rights once for all dashboards instead of once per dashboard inside the array_filter loop - tab visibility now uses the same per-item READ check as the tab content - ignore dashboard ids that do not exist in Metabase when saving rights - README: mention group and user rights management
|
Since the last review I pushed 979d2f3 (plus a merge of the current
I tested it manually against GLPI 12.0.1: plugin install/activate, tab and form permissions with Could a maintainer approve the CI workflow run? Then I'll fix anything it reports before asking for another review. Thanks! |
Rom1-B
left a comment
There was a problem hiding this comment.
No tests yet; fine given the plugin has no suite, but a small one covering getViewableDashboardIds() would be welcome.
| * | ||
| * @return bool | ||
| */ | ||
| public static function canCurrentUserViewDashboard(int $dashboardId): bool |
There was a problem hiding this comment.
Nothing calls canCurrentUserViewDashboard() anymore, nor PluginMetabaseItemright::canItemsViewDashboard() besides it. Can you drop both?
| } | ||
|
|
||
| // UPDATE right on the targeted group / user is required to change its dashboard rights. | ||
| $item->check($items_id, UPDATE); |
There was a problem hiding this comment.
With default profiles, a Technician has user UPDATE and can grant themselves every dashboard. Editing should also require the right that guards profile-based dashboard rights (also set can_update accordingly in showForItem()).
| $item->check($items_id, UPDATE); | |
| $item->check($items_id, UPDATE); | |
| Session::checkRight(Profile::$rightname, UPDATE); |
Update to better manage access to the dashboards.
Checklist before requesting a review
Description
Currently, dashboard access can only be granted per Profile. This PR adds the ability to also grant access per Group and per User, using the same rights mechanism already used for profiles.
PluginMetabaseItemrightclass, mirroringPluginMetabaseProfileright, storing rights keyed byitemtype(GrouporUser) +items_id+dashboard_id.READon the group/user shows the tab and the rights matrix,UPDATEis required to change anything (Save and "Allow/Disallow access to all"), same asPluginMetabaseProfileright. The rights are checked on the targeted group/user itself, both when displaying the tab and when saving.READ. A "No access" value on a group or user only means "no right granted there", it does not override access granted through another source.I did not add automated tests since the plugin doesn't currently have a test suite in place. I tested manually against GLPI 12.0.1 (plugin install/activate, tab and form permissions with
READonly vsREAD+UPDATE, Central visibility with profile / group / user rights, and that the batched resolution gives the same result as the previous per-dashboard check). PHP-CS-Fixer and PHPStan report nothing on the changed files.Screenshots: