{"id":20176558,"url":"https://github.com/phpmv/ubiquity-acl","last_synced_at":"2026-06-10T05:31:28.820Z","repository":{"id":55464339,"uuid":"300874849","full_name":"phpMv/ubiquity-acl","owner":"phpMv","description":"Access control lists for Ubiquity framework","archived":false,"fork":false,"pushed_at":"2023-01-04T00:41:33.000Z","size":243,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-18T12:32:15.953Z","etag":null,"topics":["php","security","ubiquity-framework"],"latest_commit_sha":null,"homepage":"https://ubiquity.kobject.net","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpMv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-03T12:26:21.000Z","updated_at":"2021-12-26T03:33:34.000Z","dependencies_parsed_at":"2023-02-01T15:00:43.600Z","dependency_job_id":null,"html_url":"https://github.com/phpMv/ubiquity-acl","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpMv%2Fubiquity-acl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpMv%2Fubiquity-acl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpMv%2Fubiquity-acl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpMv%2Fubiquity-acl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpMv","download_url":"https://codeload.github.com/phpMv/ubiquity-acl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241612024,"owners_count":19990711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","security","ubiquity-framework"],"created_at":"2024-11-14T02:10:00.106Z","updated_at":"2026-06-10T05:31:28.781Z","avatar_url":"https://github.com/phpMv.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ubiquity-acl\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpMv/ubiquity-acl/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/phpMv/ubiquity-acl/?branch=main)\n[![Build Status](https://scrutinizer-ci.com/g/phpMv/ubiquity-acl/badges/build.png?b=main)](https://scrutinizer-ci.com/g/phpMv/ubiquity-acl/build-status/main)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/phpMv/ubiquity-acl/badges/code-intelligence.svg?b=main)](https://scrutinizer-ci.com/code-intelligence)\n[![Code Coverage](https://scrutinizer-ci.com/g/phpMv/ubiquity-acl/badges/coverage.png?b=main)](https://scrutinizer-ci.com/g/phpMv/ubiquity-acl/?branch=main)\n\nAccess control lists for Ubiquity framework\n\n## Samples\n\n### Defining ACLs at runtime\n#### One by one\n```php\nAclManager::start();\nAclManager::addRole('@USER');\nAclManager::addResource('Home');\nAclManager::addPermission('READ',1);\nAclManager::allow('@USER','Home','READ');\n```\n#### By grouping\n```php\nAclManager::start();\nAclManager::addAndAllow('@USER','Home','READ');\n```\n### Defining ACLs with annotations or attributes\n#### Starting\n```php\nuse Ubiquity\\security\\acl\\AclManager;\nuse Ubiquity\\security\\acl\\persistence\\AclCacheProvider;\n\nAclManager::start();\nAclManager::initFromProviders([\n\tnew AclCacheProvider()\n]);\n```\n\n#### Defining ACLs in controllers\n\n##### A controller as a resource, authorized for a role\nWith annotations:\n```php\nnamespace controllers;\n/**\n * @resource('Main')\n * @allow('role'=\u003e'@USER')\n */\nclass TestAclController extends ControllerBase {\n\tuse AclControllerTrait;\n}\n```\n\nWith attributes:\n```php\nnamespace controllers;\nuse Ubiquity\\attributes\\items\\acl\\Resource;\nuse Ubiquity\\attributes\\items\\acl\\Allow;\n\n#[Resource('Main')]\n#[Allow(role: '@USER')]\nclass TestAclController extends ControllerBase {\n\tuse AclControllerTrait;\n}\n```\n\n#### Overriding\nIt is necessary to override the _getRole method so that it returns the role of the active user:\n\n```php\nnamespace controllers;\nuse Ubiquity\\attributes\\items\\acl\\Resource;\nuse Ubiquity\\attributes\\items\\acl\\Allow;use Ubiquity\\utils\\http\\USession;\nuse Ubiquity\\utils\\http\\USession;\n\n#[Resource('Main')]\n#[Allow(role: '@USER')]\nclass TestAclController extends ControllerBase {\n\tuse AclControllerTrait;\n\t\n\tpublic function _getRole(){\n\t    $activeUser=USession::get('activeUser');\n\t    if(isset($activeUser)){\n\t        return $activeUser-\u003egetRole();\n\t    }\n\t}\n}\n```\n\n### Defining ACLs with Database\nThe ACLs defined in the database are additional to the ACLs defined via annotations or attributes.\n\n#### Initializing\nThe initialization allows to create the tables associated to the ACLs (`Role`, `Resource`, `Permission`, `AclElement`).\nIt needs to be done only once, and in dev mode only.\n```php\nuse Ubiquity\\controllers\\Startup;\nuse Ubiquity\\security\\acl\\AclManager;\n\n$config=Startup::$config;\nAclManager::initializeDAOProvider($config, 'default');\n```\n\n#### Starting\nIn `app/config/services.php` file :\n```php\nuse Ubiquity\\security\\acl\\AclManager;\nuse Ubiquity\\security\\acl\\persistence\\AclCacheProvider;\nuse Ubiquity\\security\\acl\\persistence\\AclDAOProvider;\nuse Ubiquity\\orm\\DAO;\n\nDAO::start();//Optional, to use only if dbOffset is not default\n\nAclManager::start();\nAclManager::initFromProviders([\n\tnew AclCacheProvider(), new AclDAOProvider($config)\n]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpmv%2Fubiquity-acl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpmv%2Fubiquity-acl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpmv%2Fubiquity-acl/lists"}