{"id":20254761,"url":"https://github.com/chippyash/zend-acl-xml-builder","last_synced_at":"2025-04-11T00:03:56.188Z","repository":{"id":24891615,"uuid":"28307856","full_name":"chippyash/Zend-Acl-Xml-Builder","owner":"chippyash","description":"Provides the ability to specify a Zend 2 ACL using XML","archived":false,"fork":false,"pushed_at":"2018-07-05T17:09:43.000Z","size":70,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T00:03:50.563Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chippyash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-21T18:00:34.000Z","updated_at":"2018-07-05T17:09:44.000Z","dependencies_parsed_at":"2022-08-22T18:30:20.377Z","dependency_job_id":null,"html_url":"https://github.com/chippyash/Zend-Acl-Xml-Builder","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FZend-Acl-Xml-Builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FZend-Acl-Xml-Builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FZend-Acl-Xml-Builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FZend-Acl-Xml-Builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chippyash","download_url":"https://codeload.github.com/chippyash/Zend-Acl-Xml-Builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317705,"owners_count":21083528,"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":[],"created_at":"2024-11-14T10:34:46.599Z","updated_at":"2025-04-11T00:03:56.146Z","avatar_url":"https://github.com/chippyash.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chippyash/zend-acl-xml-builder\n\n## Quality Assurance\n\n![PHP 5.6](https://img.shields.io/badge/PHP-5.6-blue.svg)\n![PHP 7](https://img.shields.io/badge/PHP-7-blue.svg)\n[![Build Status](https://travis-ci.org/chippyash/Zend-Acl-Xml-Builder.svg?branch=master)](https://travis-ci.org/chippyash/Zend-Acl-Xml-Builder)\n[![Test Coverage](https://codeclimate.com/github/chippyash/Zend-Acl-Xml-Builder/badges/coverage.svg)](https://codeclimate.com/github/chippyash/Zend-Acl-Xml-Builder/coverage)\n[![Code Climate](https://codeclimate.com/github/chippyash/Zend-Acl-Xml-Builder/badges/gpa.svg)](https://codeclimate.com/github/chippyash/Zend-Acl-Xml-Builder)\n\nThe above badges represent the current development branch.  As a rule, I don't push\n to GitHub unless tests, coverage and usability are acceptable.  This may not be\n true for short periods of time; on holiday, need code for some other downstream\n project etc.  If you need stable code, use a tagged version. Read 'Further Documentation'\n and 'Installation'.\n \n[Test Contract](https://github.com/chippyash/Zend-Acl-Xml-Builder/blob/master/docs/Test-Contract.md) in the docs directory.\n\nPlease note that developer support for PHP5.5 was withdrawn at version 3.0.0 of this library.\nIf you need support for PHP 5.5, please use a version `\u003e=2,\u003c3`\n \n## What?\n\nProvides the ability to specify a [Zend ACL](http://framework.zend.com/manual/current/en/modules/zend.permissions.acl.intro.html) \nusing XML. The XML is validated by an XSD file which you can also use in your XML \neditor\n\n## Why?\n\nZend/Permissions/Acl is a great and lightweight way of providing access control to your\napplications, but it can be a [PITA](http://www.urbandictionary.com/define.php?term=pita) \nto configure using the native command set. As it happens, it is ideally placed, \nbecause of its structure, to be driven by an XML configuration.  \n\nThis also means that the ACL can be managed by some third party application or service.  \nIt is not beyond the wit of most to be able to write an XSL translation for \ninstance, that takes a definition from LDAP and converts to this library format \nto be able then to control the ACL from your organisation's LDAP servers.\n\n## When\n\nThe current library handles reading nested XML files (or content) and returning an ACL.\nIf you'd like new features, please suggest them in the issues tracker, or better\nstill, fork the lib and issue a pull request (but please don't forget the unit tests!)\n\n## How\n\nTo understand how to use it, see the test files, in particular, take a look at\nAclDirectorTest as a starting point and work down from there.\n\nIn essence you need to do two things\n\n1. Provide an XML definition of the ACL\n2. Tell the Director where the XML is\n\nThis library depends on the [Builder Pattern](https://github.com/chippyash/Builder-Pattern)\nand the [Strong Type](https://github.com/chippyash/Strong-Type) libraries.\n\n### Defining the XML\n\nFor the canonical truth, study the XSD file located in [src/chippyash/Zend/Acl/Xml/xsd](https://github.com/chippyash/Zend-Acl-Xml-Builder/blob/master/src/chippyash/Zend/Acl/Xml/xsd/zendacl.xsd)\n\nThere is also an example XML file used for testing located in [test/src/chippyash/Zend/Acl/Xml/fixtures](https://github.com/chippyash/Zend-Acl-Xml-Builder/blob/master/test/src/chippyash/Zend/Acl/Xml/fixtures/test.xml)\n\nThe XSD namespace is http://schema.zf4.biz/schema/zendacl. It is publicly available at the same url.\n\nYour XML file should be defined as \n\n\u003cpre\u003e\n\u0026lt;?xml version=\"1.0\" encoding=\"UTF-8\"?\u0026gt;\n\u0026lt;acl xmlns=\"http://schema.zf4.biz/schema/zendacl\"\n     xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n     xsi:schemaLocation=\"http://schema.zf4.biz/schema/zendacl http://schema.zf4.biz/schema/zendacl\"\n     \u0026gt;\n\u0026lt;/acl\u0026gt;\n\u003c/pre\u003e\n\nNB. you can replace the second part of the xsi:schemaLocation attribute to point at\na local disk version of the XSD if you want to tinker with the XSD. e.g.\n\n\u003ccode\u003exsi:schemaLocation=\"http://schema.zf4.biz/schema/zendacl ../../zendacl.xsd\"\u003c/code\u003e\n\nEssentially, Zend-ACL defines the ACL in three parts:\n\n* Roles\n* Resources\n* Rules\n\nWhilst you can define Roles and Resources independently, Rules require that you\nhave already defined Roles and Resources to act on.  Rules also allow you to set\nadditional privileges and assertions.  \n\nTo provide an ACL you must specify all three parts.\n\n#### Roles\n\n- A role can have the following optional attributes:\n    - type: string: default = \"GenericRole\". Name of your specialized role class. The default\nuses the Zend GenericRole\n    - parents: string: default = none. Comma separated list of names of parents for this role\n- Content for the role element is the role name\n\n#### Resources\n\n- A resource can have the following optional attributes:\n    - type: string: default = \"GenericResource\". Name of your specialized resource class. The default\nuses the Zend GenericResource\n    - parent: string: default = none. Name of parent for this resource. NB. unlike roles,\nresources may only have a single parent.\n- Content for the resource element is the resource name\n\n#### Rules\n\n- A rule has an obligatory attribute:\n    - type: string: one of 'ALLOW' or 'DENY'\n- A rule has the following optional arguments:\n    - roles: string: default = \"*\". comma separated list of role names that the rule applies to\n    - resources: string: default = \"*\". comma separated list of resource names that the rule applies to\n    - assertion: string: default = none. Fully namespaced class providing the assertion.  \nThe class must exist and implement the Zend\\Permissions\\Acl\\Assertion\\AssertionInterface.\nYou can find an example in [test/src/chippyash/Zend/Acl/Xml/Stubs](https://github.com/chippyash/Zend-Acl-Xml-Builder/blob/master/test/src/chippyash/Zend/Acl/Xml/Stubs/TestAssertionStub.php)\n- a rule can contain optional \\\u003cprivilege\\\u003e elements. Each \\\u003cprivilege\\\u003e element contains\nthe name of an arbitrary privilege.\n\n#### Importing definitions\n\nYou can import other ACL definitions into your definition by using the \n\n\u003cpre\u003e\n    \u0026lt;imports\u0026gt;\n        \u0026lt;import\u0026gt;[path_to_file/|../*path_to_file/]file.xml\u0026lt;import\u0026gt;\n    \u0026lt;/imports\u0026gt;\n\u003c/pre\u003e\n\nIf no path given, then expect file to be in same directory as parent file. If \npath begins .., then expect file to be in directory relative to parent file. If \npath supplied, then expect file to be in that directory.  Thus the following are\nall valid:\n\n\u003cpre\u003e\n    myfile.xml\n    ../../path/to/file.xml\n    /path/to/file.xml\n\u003c/pre\u003e\n\n#### NB\n\nAll definition items are processed in the order that they appear in the XML file.\nImports are processed first, by a L2R, depth first strategy.\n\n### Build the ACL\n\n\u003cpre\u003e\n    use Chippyash\\Zend\\Acl\\Xml\\AclDirector;\n    use Chippyash\\Type\\String\\StringType;\n\n    $location = new StringType('/location/of/my/acl.xml');\n    $director = new AclDirector($location);\n    $acl = $director-\u003ebuild();\n\u003c/pre\u003e\n\nAlternatively, you can pass in the XML to act on as a string, rather than a file.\nThe string must of course conform to the zendacl.xsd (http://schema.zf4.biz/schema/zendacl)\nschema and be valid XML.\n\n\u003cpre\u003e\n    use Chippyash\\Zend\\Acl\\Xml\\AclDirector;\n    use Chippyash\\Type\\String\\StringType;\n\n    $content = new StringType($myAclXml);\n    $director = new AclDirector($content);\n    $acl = $director-\u003ebuild();\n\u003c/pre\u003e\n\n### Changing the library\n\n1.  fork it\n2.  write the test\n3.  amend it\n4.  do a pull request\n\nFound a bug you can't figure out?\n\n1.  fork it\n2.  write the test\n3.  do a pull request\n\nNB. Make sure you rebase to HEAD before your pull request\n\n## Where?\n\nThe library is hosted at [Github](https://github.com/chippyash/Zend-Acl-Xml-Builder). It is\navailable at [Packagist.org](https://packagist.org/packages/chippyash/zend-acl-xml-builder)\n\n### Installation\n\nInstall [Composer](https://getcomposer.org/)\n\n#### For production\n\nadd\n\n\u003cpre\u003e\n    \"chippyash/zend-acl-xml-builder\": \"\u003e=3,\u003c4\"\n\u003c/pre\u003e\n\nto your composer.json \"requires\" section\n\n#### For development\n\nClone this repo, and then run Composer in local repo root to pull in dependencies\n\n\u003cpre\u003e\n    git clone git@github.com:chippyash/Zend-Acl-Xml-Builder.git ZendAclBuilder\n    cd ZendAclBuilder\n    composer install --dev\n\u003c/pre\u003e\n\nTo run the tests:\n\n\u003cpre\u003e\n    cd ZendAclBuilder\n    vendor/bin/phpunit -c test/phpunit.xml test/\n\u003c/pre\u003e\n\n## Other stuff\n\nCheck out [ZF4 Packages](http://zf4.biz/packages?utm_source=github\u0026utm_medium=web\u0026utm_campaign=blinks\u0026utm_content=zendaclxmlbuilder) for more packages\n\n## License\n\nThis software library is released under the [BSD 3 Clause license](https://opensource.org/licenses/BSD-3-Clause)\n\nThis software library is Copyright (c) 2015-2018, Ashley Kitson, UK\n\n## History\n\nV0...  pre releases\n\nV1.0.0 First version\n\nV1.1.0 New feature: Namespaced the XSD and placed on public server\n\nV1.2.0 New features: \n\n- ACL definitions can import other definitions\n- XML can be passed in as string as well as file\n\nV1.2.1 Remove hard dependency on Zend-ACL version\n\nV2.0.0 BC Break: change chippyash\\Zend\\Acl namespace to Chippyash\\Zend\\Acl\n\nV2.0.1 moved from coveralls to codeclimate\n\nV2.0.2 Add link to packages\n\nV2.0.3 Verify PHP 7 compatibility\n\nV2.0.4 Update dependencies\n\nV2.0.5 update composer - forced by packagist composer.json format change\n\nV3.0.0 BC Break. Withdraw support for old PHP versions\n\nV3.1.0 Change of license from GPL V3 to BSD 3 Clause\n\nV3.1.1 readme update \n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Fzend-acl-xml-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchippyash%2Fzend-acl-xml-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Fzend-acl-xml-builder/lists"}