{"id":16184338,"url":"https://github.com/mattmezza/aclify","last_synced_at":"2025-03-19T02:31:11.222Z","repository":{"id":62525308,"uuid":"121607919","full_name":"mattmezza/aclify","owner":"mattmezza","description":"A simple and plain ACL component based on a YAML file.","archived":false,"fork":false,"pushed_at":"2018-05-29T15:44:20.000Z","size":18,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-11T07:09:48.537Z","etag":null,"topics":["acl","kiss","permission-manager","php7","roles","yaml"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattmezza.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":"2018-02-15T08:52:41.000Z","updated_at":"2023-09-08T17:36:43.000Z","dependencies_parsed_at":"2022-11-02T14:15:50.273Z","dependency_job_id":null,"html_url":"https://github.com/mattmezza/aclify","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Faclify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Faclify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Faclify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Faclify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattmezza","download_url":"https://codeload.github.com/mattmezza/aclify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221720378,"owners_count":16869476,"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":["acl","kiss","permission-manager","php7","roles","yaml"],"created_at":"2024-10-10T07:09:53.940Z","updated_at":"2024-10-27T19:09:03.725Z","avatar_url":"https://github.com/mattmezza.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/mattmezza/aclify.svg?branch=master)](https://travis-ci.org/mattmezza/aclify)\n\n# aclify\nA simple and plain ACL component based on a YAML file.\n## Specs\nAclify is a really simple component that halps you manage roles and abilities for a small set of users.\n\nHave you ever been in the context of a small projects that requires no database, no authentication (cause it is accomplished using an external provider), small set of roles and abilities???\n\nIf you have, well, this package is for you.\n\nAclify allows you to define roles, each with a set of abilities (operations you can do if you belong to the role). It also allows you to specify for each user, a set of roles.\n\nIt can be used in a tight way, coupled with your User object representation or it can be also used as an external component you call specifying the user each time.\n\n## Installation\n\n`composer require mattmezza/aclify`\n\n## Usage \n\nWrite down your users and roles with abilities in a YAML file as follows:\n\n```yaml\nroles: \n  billing: \n    - payments\n  marketing: \n    - mailchimp\n    - facebook\n  support: \n    - cms_tools\nusers: \n  mary: \n    - marketing\n    - billing\n    - support\n  gigi: \n    - support\n\n```\nWe specified in this way three roles: `billing` (users with this role can manage the `payments`), `marketing` (users with this role can access to tools like `mailchimp` or `facebook`) and `support` (users with this role can access the `cms_tools`).\n\nThen we specified the users allowed: `mary` is an advanced user, she can check pretty much everything (`marketing`, `support`, `billing`) while `gigi` is a basic user with just the `support` abilities enabled.\n\n### Usage tight to your User object\nIf you wanna use Aclify tight with your User object representation you can do that by extending the abstract class `Aclify\\ACLUser` which forces you to define two methods (user id and acl object retrieval - you can use your project's dependency injection component) and gives you some inherited methods to check whether the `User` can or cannot use some abilities.\n\nDefine your User object as follows (you can add your methods to the class): \n\n```php\nuse Aclify\\ACL;\n\nclass User extends ACLUser\n{\n    private $acl;\n    private $id;\n    public function __construct(ACL $acl, string $id) \n    {\n        $this-\u003eacl = $acl;\n        $this-\u003eid = $id;\n    }\n    public function getACL() : ACL\n    {\n        return $this-\u003eacl;\n    }\n    public function getId() : string\n    {\n        return $this-\u003eid;\n    }\n}\n```\n\nThen use it in this way:\n\n```php\n$acl = new Aclify\\ACL();\n$gigi = new User($acl, \"gigi@domain.com\");\nif ($gigi-\u003ecan(\"create_post\"))\n{\n    // ...\n}\n```\n\n### Usage not tight to the User object\n\nIf you don't wanna bind your user representation to the component you can avoid extending the class provided `ACLUser` and you can just use `ACL` instead, pls do as follow:\n\n```php\n$acl = new Aclify\\ACL();\nif ($acl-\u003ecan(\"gigi@domain.com\", \"create_post\"))\n{\n    // ...\n}\n```\n\n### Exceptions\n\nWhen instanciating the `ACL` class, the component tries to read the specs from a default `./acl.yml` file. If you wanna specify a different file you can pass the file path as a parameter in the contructor. If the file is not readable or not found (or not a yaml file) an exception will be thrown, so better use it in this way:\n\n```php\nuse Aclify\\ACL;\nuse Aclify\\Exceptions\\MissingACLSpecsFile;\n\ntry {\n    $acl = new ACL(\"./config/acl-new.yml\");\n    // ...\n} catch (MissingACLSpecsFile $e) {\n    // do something with $e\n}","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattmezza%2Faclify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattmezza%2Faclify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattmezza%2Faclify/lists"}