Refactor ACL logic into AclRuleManager service #193
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extracts assertion-based ACL deny rules from
Module::addAclRules()into a dedicated, testable service class to improve separation of concerns.Note: This PR is rebased on the
developbranch and builds upon the merged work from PR #190 (copilot/refactor-teams-module-authorization), which introduced the fullTeamRolePermissionAssertionimplementation with real authorization logic.Changes
New service:
AclRuleManagerapplies assertion-based deny rules for Omeka resources and adapters across controlled roles (excluding global_admin)Uses existing assertion: Leverages the
TeamRolePermissionAssertionfrom PR Refactor Teams authorization to use Laminas ACL assertions #190 with full team-based authorization logic (not a placeholder)Service registration: Added
AclRuleManagertoservice_managerconfiguration inmodule.config.phpwith factory using::classconstantsSimplified Module.php:
addAclRules()now delegates ACL deny rule configuration toAclRuleManager::applyRules(), reducing the method from ~80 lines to ~27 lines while retaining team-specific controller permissions and site creation controlsTest coverage: Unit tests verify ACL deny rules override previously allowed permissions and that global_admin role is excluded from restrictions
Before
After
The extracted logic uses constants from
TeamRolePermissionAssertionto ensure synchronization between ACL rules and assertion logic, and wraps the assertion inAssertionNegationto deny privileges conditionally based on team permissions.Original prompt
Hello Copilot,
Please open a new pull request against the
developmentbranch of theUIUCLibrary/teamsrepository with the title "Refactor ACL logic into a new AclRuleManager service".The goal of this pull request is to refactor the Access Control List (ACL) logic out of
Module.phpinto a new, dedicated, and testable service class. This improves code quality by separating concerns.The pull request should contain the following exact changes:
1. Create a new service class
AclRuleManagersrc/Service/AclRuleManager.php2. Create a factory for the new service
src/Service/AclRuleManagerFactory.php3. Create a new unit test for the service
tests/Service/AclRuleManagerTest.php4. Update the module configuration
config/module.config.phpAclRuleManagerFactoryto theservice_manager.factoriesarray....
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.