{ "info": { "author": "Mark Vartanyan", "author_email": "kolypto@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "|Build Status|\n\nMiracle\n=======\n\nMiracle is an ACL for Python that was designed to be well-structuted,\nsimple yet exhaustive. It uses *permissions* defined on *resources*, and\n*roles* are granted with the access to them.\n\nTo be a universal tool, it does not include any special cases, does not\nforce you to persist and does not insist on any formats or conventions.\n\nMaximum flexibility and total control. Enjoy! :)\n\nHighlights:\n\n- Inspired by `miracle `__\n for NodeJS ;\n- Simple core\n- No restrictions on authorization entities\n- Unit-tested\n\nTable of Contents\n=================\n\n- Define The Structure\n\n - Acl\n - Create\n\n - add\\_role(role)\n - add\\_roles(roles)\n - add\\_resource(resource)\n - add\\_permission(resource, permission)\n - add(structure)\n\n - Remove\n\n - remove\\_role(role)\n - remove\\_resource(resource)\n - remove\\_permission(resource, permission)\n - clear()\n\n - Get\n\n - get\\_roles()\n - get\\_resources()\n - get\\_permissions(resource)\n - get()\n\n - Export and Import\n\n- Authorize\n\n - Grant Permissions\n\n - grant(role, resource, permission)\n - grants(grants)\n - revoke(role, resource, permission)\n - revoke\\_all(role[, resource])\n\n - Check Permissions\n\n - check(role, resource, permission)\n - check\\_any(roles, resource, permission)\n - check\\_all(roles, resource, permission)\n\n - Show Grants\n\n - which\\_permissions(role, resource)\n - which\\_permissions\\_any(roles, resource)\n - which\\_permissions\\_all(roles, resource)\n - which(role)\n - which\\_any(roles)\n - which\\_all(roles)\n - show()\n\nDefine The Structure\n====================\n\nAcl\n---\n\nTo start using miracle, instantiate the ``Acl`` object:\n\n.. code:: python\n\n from acl import Acl\n acl = Acl()\n\nThe ``Acl`` object keeps track of your *resources* and *permissions*\ndefined on them, handles *grants* over *roles* and provides utilities to\nmanage them. When configured, you can check the access against the\ndefined state.\n\nCreate\n------\n\nMethods from this section allow you to build the *structure*: list of\nroles, resources and permissions.\n\nIt's not required that you have the structure defined before you start\ngranting the access: the ``grant()`` method implicitly creates all\nresources and permissions that were not previously defined.\n\nStart with defining the *resources* and *permissions* on them, then you\ncan grant a *role* with the access to some permissions on a resource.\n\nFor roles, resources & permissions, any hashable objects will do.\n\n``add_role(role)``\n~~~~~~~~~~~~~~~~~~\n\nDefine a role.\n\n- ``role``: the role to define.\n\nThe role will have no permissions granted, but will appear in\n``get_roles()``.\n\n.. code:: python\n\n acl.add_role('admin')\n acl.get_roles() # -> {'admin'}\n\n``add_roles(roles)``\n~~~~~~~~~~~~~~~~~~~~\n\nDefine multiple roles\n\n- ``roles``: An iterable of roles\n\n.. code:: python\n\n acl.add_roles(['admin', 'root'])\n acl.get_roles() # -> {'admin', 'root'}\n\n``add_resource(resource)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nDefine a resource.\n\n- ``resources``: the resource to define.\n\nThe resource will have no permissions defined but will appear in\n``get_resources()``.\n\n.. code:: python\n\n acl.add_resource('blog')\n acl.get_resources() # -> {'blog'}\n\n``add_permission(resource, permission)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nDefine a permission on a resource.\n\n- ``resource``: the resource to define the permission on. Is created if\n was not previously defined.\n- ``permission``: the permission to define.\n\nThe defined permission is not granted to anyone, but will appear in\n``get_permissions(resource)``.\n\n.. code:: python\n\n acl.add_permission('blog', 'post')\n acl.get_permissions('blog') # -> {'post'}\n\n``add(structure)``\n~~~~~~~~~~~~~~~~~~\n\nDefine the whole resource/permission structure with a single dict.\n\n- ``structure``: a dict that maps resources to an iterable of\n permissions.\n\n.. code:: python\n\n acl.add({\n 'blog': ['post'],\n 'page': {'create', 'read', 'update', 'delete'},\n })\n\nRemove\n------\n\n``remove_role(role)``\n~~~~~~~~~~~~~~~~~~~~~\n\nRemove the role and its grants.\n\n- ``role``: the role to remove.\n\n.. code:: python\n\n acl.remove_role('admin')\n\n``remove_resource(resource)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRemove the resource along with its grants and permissions.\n\n- ``resource``: the resource to remove.\n\n.. code:: python\n\n acl.remove_resource('blog')\n\n``remove_permission(resource, permission)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRemove the permission from a resource.\n\n- ``resource``: the resource to remove the permission from.\n- ``permission``: the permission to remove.\n\nThe resource is not implicitly removed: it remains with an empty set of\npermissions.\n\n.. code:: python\n\n acl.remove_permission('blog', 'post')\n\n``clear()``\n~~~~~~~~~~~\n\nRemove all roles, resources, permissions and grants.\n\nGet\n---\n\n``get_roles()``\n~~~~~~~~~~~~~~~\n\nGet the set of defined roles.\n\n.. code:: python\n\n acl.get_roles() # -> {'admin', 'anonymous', 'registered'}\n\n``get_resources()``\n~~~~~~~~~~~~~~~~~~~\n\nGet the set of defined resources, including those with empty permissions\nset.\n\n.. code:: python\n\n acl.get_resources() # -> {'blog', 'page', 'article'}\n\n``get_permissions(resource)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nGet the set of permissions for a resource.\n\n- ``resource``: the resource to get the permissions for.\n\n.. code:: python\n\n acl.get_permissions('page') # -> {'create', 'read', 'update', 'delete'}\n\n``get()``\n~~~~~~~~~\n\nGet the *structure*: hash of all resources mapped to their permissions.\n\nReturns a dict: ``{ resource: set(permission,...), ... }``.\n\n.. code:: python\n\n acl.get() # -> { blog: {'post'}, page: {'create', ...} }\n\nExport and Import\n-----------------\n\nThe ``Acl`` class is picklable:\n\n.. code:: python\n\n acl = miracle.Acl()\n save = acl.__getstate__()\n\n #...\n\n acl = miracle.Acl()\n acl.__setstate__(save)\n\nAuthorize\n=========\n\nGrant Permissions\n-----------------\n\n``grant(role, resource, permission)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nGrant a permission over resource to the specified role.\n\n- ``role``: The role to grant the access to\n- ``resource``: The resource to grant the access over\n- ``permission``: The permission to grant with\n\nRoles, resources and permissions are implicitly created if missing.\n\n.. code:: python\n\n acl.grant('admin', 'blog', 'delete')\n acl.grant('anonymous', 'page', 'view')\n\n``grants(grants)``\n~~~~~~~~~~~~~~~~~~\n\nAdd a structure of grants to the Acl.\n\n- ``grants``: A hash in the following form:\n ``{ role: { resource: set(permission) } }``.\n\n.. code:: python\n\n acl.grants({\n 'admin': {\n 'blog': ['post'],\n },\n 'anonymous': {\n 'page': ['view']\n }\n })\n\n``revoke(role, resource, permission)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRevoke a permission over a resource from the specified role.\n\n.. code:: python\n\n acl.revoke('anonymous', 'page', 'view')\n acl.revoke('user', 'account', 'delete')\n\n``revoke_all(role[, resource])``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRevoke all permissions from the specified role for all resources. If the\noptional ``resource`` argument is provided - removes all permissions\nfrom the specified resource.\n\n.. code:: python\n\n acl.revoke_all('anonymous', 'page') # revoke all permissions from a single resource\n acl.revoke_all('anonymous') # revoke permissions from all resources\n\nCheck Permissions\n-----------------\n\n``check(role, resource, permission)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTest whether the given role has access to the resource with the\nspecified permission.\n\n- ``role``: The role to check\n- ``resource``: The protected resource\n- ``permission``: The required permission\n\nReturns a boolean.\n\n.. code:: python\n\n acl.check('admin', 'blog') # True\n acl.check('anonymous', 'page', 'delete') # -> False\n\n``check_any(roles, resource, permission)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTest whether *any* of the given roles have access to the resource with\nthe specified permission.\n\n- ``roles``: An iterable of roles.\n\nWhen no roles are provided, returns False.\n\n``check_all(roles, resource, permission)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTest whether *all* of the given roles have access to the resource with\nthe specified permission.\n\n- ``roles``: An iterable of roles.\n\nWhen no roles are provided, returns False.\n\nShow Grants\n-----------\n\nwhich\\_permissions(role, resource)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nList permissions that the provided role has over the resource:\n\n.. code:: python\n\n acl.which_permissions('admin', 'blog') # -> {'post'}\n\nwhich\\_permissions\\_any(roles, resource)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nList permissions that any of the provided roles have over the resource:\n\n.. code:: python\n\n acl.which_permissions_any(['anonymous', 'registered'], 'page') # -> {'view'}\n\nwhich\\_permissions\\_all(roles, resource)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nList permissions that all of the provided roles have over the resource:\n\n.. code:: python\n\n acl.which_permissions_all(['anonymous', 'registered'], 'page') # -> {'view'}\n\n``which(role)``\n~~~~~~~~~~~~~~~\n\nCollect grants that the provided role has:\n\n.. code:: python\n\n acl.which('admin') # -> { blog: {'post'} }\n\n``which_any(roles)``\n~~~~~~~~~~~~~~~~~~~~\n\nCollect grants that any of the provided roles have (union).\n\n.. code:: python\n\n acl.which(['anonymous', 'registered']) # -> { page: ['view'] }\n\n``which_all(roles)``\n~~~~~~~~~~~~~~~~~~~~\n\nCollect grants that all of the provided roles have (intersection):\n\n.. code:: python\n\n acl.which(['anonymous', 'registered']) # -> { page: ['view'] }\n\n``show()``\n~~~~~~~~~~\n\nGet all current grants.\n\nReturns a dict ``{ role: { resource: set(permission) } }``.\n\n.. code:: python\n\n acl.show() # -> { admin: { blog: ['post'] } }\n\n.. |Build Status| image:: https://travis-ci.org/kolypto/py-miracle.png?branch=master\n :target: https://travis-ci.org/kolypto/py-miracle", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kolypto/py-miracle", "keywords": "acl,rbac,authorization", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "miracle-acl", "package_url": "https://pypi.org/project/miracle-acl/", "platform": "any", "project_url": "https://pypi.org/project/miracle-acl/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/kolypto/py-miracle" }, "release_url": "https://pypi.org/project/miracle-acl/0.0.4-1/", "requires_dist": null, "requires_python": null, "summary": "Flexible role-based authorization solution that is a pleasure to use", "version": "0.0.4-1" }, "last_serial": 4677349, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "a2c6d555b0650b6e528fb6c5caaccc8d", "sha256": "64fdafe3f8632567fe03b7f981bfb0244199ac485cf5abcffd29b4aff3eb1ebc" }, "downloads": -1, "filename": "miracle_acl-0.0.1-py2.7.egg", "has_sig": false, "md5_digest": "a2c6d555b0650b6e528fb6c5caaccc8d", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 8885, "upload_time": "2014-01-03T16:31:28", "url": "https://files.pythonhosted.org/packages/97/ad/450a209630f1e9e141b1dec0eb8cf17307d821be0e07fbeb0c9f7b674bf9/miracle_acl-0.0.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "9763e70737fea0a2d1f9a40d6fe51854", "sha256": "142c200e82aa63ca510a9c6e445524363fbe4bc84a31e3d11accd8fe37e6ea74" }, "downloads": -1, "filename": "miracle-acl-0.0.1.tar.gz", "has_sig": false, "md5_digest": "9763e70737fea0a2d1f9a40d6fe51854", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8129, "upload_time": "2014-01-03T16:31:26", "url": "https://files.pythonhosted.org/packages/5f/a2/dfc92c62ee4f3926ff41e46cdb95aa4ea97a6c851dd282deff065e65c3e5/miracle-acl-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "54f5611a33a5b84af899b6959d3a561f", "sha256": "8ed5185e32e3fa062339028fd993c2a9a2528cbd7c3b48acb1cfde09c89f4b5f" }, "downloads": -1, "filename": "miracle_acl-0.0.2-py2.7.egg", "has_sig": false, "md5_digest": "54f5611a33a5b84af899b6959d3a561f", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 9245, "upload_time": "2014-01-03T21:20:12", "url": "https://files.pythonhosted.org/packages/8d/79/cfa67d0ce29cd4acd868223ab6622acac3c04067941c1bc86a79e806e1b7/miracle_acl-0.0.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "aa404aef9ad930dae686d3decd039d31", "sha256": "ca8a794ea1d6c57c3750c20f2ea7332c965fb14b1500c00447a82db5f1d57951" }, "downloads": -1, "filename": "miracle-acl-0.0.2.tar.gz", "has_sig": false, "md5_digest": "aa404aef9ad930dae686d3decd039d31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8407, "upload_time": "2014-01-03T21:20:10", "url": "https://files.pythonhosted.org/packages/90/8b/bfe70e5c8fa277911936fe414fe0c06e3279039b66691534ffa2c71fc254/miracle-acl-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "c4e53abb5c7a42fb74820e520f2cc49e", "sha256": "0aac985ae4133b988f53752093d1f3702e58438edbda9f14d34ac2587adfb6aa" }, "downloads": -1, "filename": "miracle_acl-0.0.3-py2.7.egg", "has_sig": false, "md5_digest": "c4e53abb5c7a42fb74820e520f2cc49e", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 9826, "upload_time": "2014-01-08T00:02:40", "url": "https://files.pythonhosted.org/packages/d7/bc/c3a0fe519a65e5c5c9b0207c78d6484f2e2f157f94029a3c28b9b881675d/miracle_acl-0.0.3-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "05414f6fe9cb9f87094bcdeb207bcf04", "sha256": "9ab1a0e6458540a22df06accf4c4d0636fa22e9a0416fce02c2b056095ea4c17" }, "downloads": -1, "filename": "miracle-acl-0.0.3.tar.gz", "has_sig": false, "md5_digest": "05414f6fe9cb9f87094bcdeb207bcf04", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8973, "upload_time": "2014-01-08T00:02:37", "url": "https://files.pythonhosted.org/packages/6f/88/c897ef4a289099f23dbe834c92202d5836b7d4d6996cbaaf21724413ecca/miracle-acl-0.0.3.tar.gz" } ], "0.0.4-0": [ { "comment_text": "built for Linux-3.13.0-32-generic-x86_64-with-glibc2.4", "digests": { "md5": "0b614787f7ff89e12a12fe2f26a25214", "sha256": "e72403ddeb1328296c12c5b85ae287df1946434046901e020e65f7279328cf1d" }, "downloads": -1, "filename": "miracle-acl-0.0.4-0.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "0b614787f7ff89e12a12fe2f26a25214", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 8745, "upload_time": "2014-07-24T12:05:13", "url": "https://files.pythonhosted.org/packages/aa/fc/1e39076aaee80fd9e026fae203f86787fbd276b17cf606a54e360fb7e676/miracle-acl-0.0.4-0.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "2e33fd5488209393cbe326d6bfc23fbe", "sha256": "1059d7dc4f57da96436edbf6d9beadd59dc37f7698bd884c75372e79302f87bd" }, "downloads": -1, "filename": "miracle-acl-0.0.4-0.tar.gz", "has_sig": false, "md5_digest": "2e33fd5488209393cbe326d6bfc23fbe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9536, "upload_time": "2014-07-24T12:05:09", "url": "https://files.pythonhosted.org/packages/9e/d5/c85b86b629b872cfb426030af7665234bb2817a2b6171847120381579869/miracle-acl-0.0.4-0.tar.gz" } ], "0.0.4-1": [ { "comment_text": "", "digests": { "md5": "5f3f729d2200d6797ba9f3cc4356c79d", "sha256": "4149fd87213f43835b4b799350cc8dec4fe9bee21146fa42ab651a74f1af09d1" }, "downloads": -1, "filename": "miracle_acl-0.0.4_1-py2-none-any.whl", "has_sig": false, "md5_digest": "5f3f729d2200d6797ba9f3cc4356c79d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9924, "upload_time": "2014-08-14T15:51:19", "url": "https://files.pythonhosted.org/packages/6a/b8/dfd25d26c26d15f331bb79a707520b2d775fffffa36c834ecc905b5a4b66/miracle_acl-0.0.4_1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e72a9d8fb42b18f7ce170d0b99e8c031", "sha256": "b78240a40153334d1b3e2ea0cb06f34e067a146d8eacc68c9c243e84cb3175ea" }, "downloads": -1, "filename": "miracle-acl-0.0.4-1.tar.gz", "has_sig": false, "md5_digest": "e72a9d8fb42b18f7ce170d0b99e8c031", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9663, "upload_time": "2014-08-14T15:51:13", "url": "https://files.pythonhosted.org/packages/bd/1c/7d4e862a77ef7269e42a0f78e5f0a27e4d6cd1b3bb6d908b8735548ce73a/miracle-acl-0.0.4-1.tar.gz" }, { "comment_text": "", "digests": { "md5": "510b6bde509b89038dd7aaf689758daa", "sha256": "a4932d5039b539fde82053a824e18b9ba0d8fcc2c1d95dfdf2bbeaf8d553f8f1" }, "downloads": -1, "filename": "miracle_acl-0.0.4.post1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "510b6bde509b89038dd7aaf689758daa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10292, "upload_time": "2019-01-09T15:46:54", "url": "https://files.pythonhosted.org/packages/72/e1/9d1ff7bb16024fc8f6494ead2fd5a1deea7959181780bbd85e92eea6297f/miracle_acl-0.0.4.post1-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5f3f729d2200d6797ba9f3cc4356c79d", "sha256": "4149fd87213f43835b4b799350cc8dec4fe9bee21146fa42ab651a74f1af09d1" }, "downloads": -1, "filename": "miracle_acl-0.0.4_1-py2-none-any.whl", "has_sig": false, "md5_digest": "5f3f729d2200d6797ba9f3cc4356c79d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9924, "upload_time": "2014-08-14T15:51:19", "url": "https://files.pythonhosted.org/packages/6a/b8/dfd25d26c26d15f331bb79a707520b2d775fffffa36c834ecc905b5a4b66/miracle_acl-0.0.4_1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e72a9d8fb42b18f7ce170d0b99e8c031", "sha256": "b78240a40153334d1b3e2ea0cb06f34e067a146d8eacc68c9c243e84cb3175ea" }, "downloads": -1, "filename": "miracle-acl-0.0.4-1.tar.gz", "has_sig": false, "md5_digest": "e72a9d8fb42b18f7ce170d0b99e8c031", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9663, "upload_time": "2014-08-14T15:51:13", "url": "https://files.pythonhosted.org/packages/bd/1c/7d4e862a77ef7269e42a0f78e5f0a27e4d6cd1b3bb6d908b8735548ce73a/miracle-acl-0.0.4-1.tar.gz" }, { "comment_text": "", "digests": { "md5": "510b6bde509b89038dd7aaf689758daa", "sha256": "a4932d5039b539fde82053a824e18b9ba0d8fcc2c1d95dfdf2bbeaf8d553f8f1" }, "downloads": -1, "filename": "miracle_acl-0.0.4.post1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "510b6bde509b89038dd7aaf689758daa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10292, "upload_time": "2019-01-09T15:46:54", "url": "https://files.pythonhosted.org/packages/72/e1/9d1ff7bb16024fc8f6494ead2fd5a1deea7959181780bbd85e92eea6297f/miracle_acl-0.0.4.post1-py2.py3-none-any.whl" } ] }