{ "info": { "author": "Alex Ough", "author_email": "alex.ough@sungardas.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: Free for non-commercial use", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Porper (Portable Permission Controller)\n\nhttps://pypi.python.org/pypi/porper\n\nOverview\n=================\n\n![porper][porper-image]\n\nThis is a library to provide the permission control on resources in serverless environment.\n\nWhen implementing applications using existing frameworks, you can manage permissions on resources using the module they provide, but they are not available when you implement applications using serverless computing like AWS Lambda.\n\nThis is a very simple RBAC (Role Based Access Controller) library to manage permissions based on their privileges.\n\n## Installation\n\nNOTE: Python 2.7\n\n```python\npip install porper\n```\n\nDatabase Initialization\n```\n$ mysql -h -u -p < porper_initial.sql\n```\n\n## How to use Google+ and Github Authentication\n\nIf you plan to use Google+ and/or GitHub authentications, set related values either as an environment variables or in a config.json. (Please see next section, 'How to provide related info')\n\nPlease see these 2 sites to find out how to setup OpenID connect\n\nGoogle+ : https://developers.google.com/identity/protocols/OpenIDConnect\n\nGitHut : https://developer.github.com/v3/oauth/\n\n## How to provide related info\n\nThere are 2 ways to set necessary information\n\nUsing Environment Variables\n```\nexport MYSQL_HOST=\nexport MYSQL_USER=\nexport MYSQL_PASSWORD=\nexport MYSQL_DATABASE=\n\nexport GOOGLE_TOKENINFO_ENDPOINT=https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=\n\nexport GITHUB_AUTH_ENDPOINT=https://github.com/login/oauth\nexport GITHUB_API_ENDPOINT=https://api.github.com\nexport GITHUB_CLIENT_ID=\nexport GITHUB_CLIENT_SECRET=\n```\n\nUsing 'config.json' that needs to be placed in the root of porper library\n```\n{\n \"mysql\": {\n \"host\": \"\",\n \"username\": \"\",\n \"password\": \"\",\n \"database\": \"\"\n },\n \"google\": {\n \"tokeninfo_endpoint\": \"https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=\"\n },\n \"github\": {\n \"auth_endpoint\": \"https://github.com/login/oauth\",\n \"api_endpoint\": \"https://api.github.com\",\n \"client_id\": \"\",\n \"client_secret\": \"\"\n }\n}\n```\n\n## How to get mysql connection to the Porper database\n\n```\nfrom porper.models.connection import mysql_connection\nconnection = mysql_connection()\n```\n\n## How to authenticate\n\n```\n# For Google+ Auth\nfrom porper.controllers.google_auth_controller import GoogleAuthController\ngoogleAuthController = GoogleAuthController(connection)\nuser_info = googleAuthController.authenticate(id_token)\n\n# For GitHub Auth\nfrom porper.controllers.github_auth_controller import GithubAuthController\ngithubAuthController = GithubAuthController(connection)\nuser_info = githubAuthController.authenticate(code, state)\n\n# 'access_token' is used when sending following requests\naccess_token = user_info['access_token']\n```\n\n## How to manage roles\n\n### A couple of roles will be created during the database initialization\n```\n('435a6417-6c1f-4d7c-87dd-e8f6c0effc7a','public')\n('ffffffff-ffff-ffff-ffff-ffffffffffff','admin')\n```\n\n### To create a new role\nYou must be the admin.\n```\nparams = {\n \"name\": \"\"\n}\nfrom porper.controllers.role_controller import RoleController\nroleController = RoleController(connection)\nroleController.create(access_token, params)\n```\n\n### To find roles\n```\nroleController.find_all(access_token)\n```\n> if you're the admin, it will return all roles\n\n> otherwise, return all roles where you're belong\n\n\n## How to manage users\n\nThe first user logging into the system will be added as an admin automatically\n\n### To invite users\nYou have to invite them first and you must be either the admin or the role admin of the role where the new user will belong\n```\nparams = {\n \"email\": \"\",\n \"role_id\": \"\",\n \"is_admin\": \"<0_or_1>\"\n}\nfrom porper.controllers.invited_user_controller import InvitedUserController\ninvited_user_controller = InvitedUserController(connection)\ninvited_user_controller.create(access_token, params)\n```\n\n### To find invited users\n```\nparams = {}\ninvited_user_controller.find_all(access_token, params)\n```\n> if you're the admin, it will return all invited users\n\n> if you're the role admin of one or more roles, it will return all invited users of the roles where you're the role admin\n\n> otherwise, it will raise an exception of 'not permitted'\n\n```\nparams = {\n \"role_id\": \"\"\n}\ninvited_user_controller.find_all(access_token, params)\n```\n> if you're the admin or a role admin of the given role, it will return all invited users of the given role\n\n> otherwise, it will raise an exception of 'not permitted'\n\nOnce the invited users log in successfully for the first time, they will be automatically registered and added to the roles specified during invitation\n\n\n### To find registered user\n```\nparams = {}\nfrom porper.controllers.user_controller import UserController\nuserController = UserController(connection)\nuserController.find_all(access_token, params)\n```\n> if you're the admin, it will return all users\n\n> if you're the role admin of one or more roles, it will return all users of the roles where you're the role admin\n\n> otherwise, it will return yourself\n\n```\nparams = {\n \"role_id\": \"\"\n}\nuserController.find_all(access_token, params)\n```\n> if you're the admin or a member of the given role, it will return all users of the given role\n\n> otherwise, it will raise an exception of 'not permitted'\n\n```\nparams = {\n \"id\": \"\",\n \"email\": \"\"\n}\nuserController.find_all(access_token, params)\n```\n> It will return a specific user with the given id or email address\n\n\n### To assign a user to a role\nYou must be either the admin or the role admin.\n\n```\nparams = {\n \"user_id\": \"\",\n \"role_id\": \"\",\n \"is_admin\": \"<0 or 1>\"\n}\nfrom porper.controllers.user_controller import UserController\nuserController = UserController(connection)\nuserController.create(access_token, params)\n```\n\n\n## How to create a controller & model for a custom resource\n\n### Controller\n```\nfrom porper.controllers.resource_controller import ResourceController\n\nclass DemoController(ResourceController):\n\n def __init__(self, permission_connection):\n ResourceController.__init__(self, None, None, permission_connection)\n self.resource = 'demo'\n\n from demo import Demo\n self.model = Demo(permission_connection)\n\n # redefine this method if necessary\n def create(self, access_token, params):\n return ResourceController.create(self, access_token, params)\n\n # redefine this method if necessary\n def update(self, access_token, params):\n return ResourceController.update(self, access_token, params)\n\n # redefine this method if necessary\n def delete(self, access_token, params):\n return ResourceController.delete(self, access_token, params)\n\n # redefine this method if necessary\n def find_all(self, access_token, params):\n return ResourceController.find_all(self, access_token, params)\n\n # redefine this method if necessary\n def find_one(self, access_token, params):\n return ResourceController.find_one(self, access_token, params)\n```\n\n### Model\n```\nclass Demo:\n\n def __init__(self, connection):\n self.connection = connection\n\n # implement how to create a new instance\n def create(self, params):\n pass\n\n # implement how to update an instance\n def update(self, params):\n pass\n\n # implement how to delete an instance\n def delete(self, params):\n pass\n\n # implement how to find a specific instance(s)\n def find(self, params):\n pass\n\n```\n\n## How to manage permissions\n\n### To gran permissions\n```\nfrom porper.controllers.permission_controller import PermissionController\npermission_controller = PermissionController(connection)\npermitted_user_id = \"\"\n\n# by user_id\npermission_params = {\n \"user_id\": \"\",\n \"resource\": \"\",\n \"value\": \"<* or resource_id>\",\n \"action\": \"\"\n}\npermission_controller.create(None, permission_params, permitted_user_id)\n\n# by role_id\npermission_params = {\n \"role_id\": \"\",\n \"resource\": \"\",\n \"value\": \"<* or resource_id>\",\n \"action\": \"\"\n}\npermission_controller.create(None, permission_params, permitted_user_id)\n```\n\n### To revoke permissions\n```\nfrom porper.controllers.permission_controller import PermissionController\npermission_controller = PermissionController(connection)\npermitted_user_id = \"\"\n\n# by permission id\npermission_params_by_id = {\n \"id\": \"\"\n}\npermission_controller.delete(None, permission_params, permitted_user_id)\n\n# by user_id\npermission_params_by_user_id = {\n \"user_id\": \"\",\n \"resource\": \"\",\n \"value\": \"<* or resource_id>\",\n \"action\": \"\"\n}\npermission_controller.delete(None, permission_params, permitted_user_id)\n\n# by role_id\npermission_params_by_user_id = {\n \"role_id\": \"\",\n \"resource\": \"\",\n \"value\": \"<* or resource_id>\",\n \"action\": \"\"\n}\npermission_controller.delete(None, permission_params, permitted_user_id)\n```\n\n## Sungard Availability Services | Labs\n[![Sungard Availability Services | Labs][labs-image]][labs-github-url]\n\nThis project is maintained by the Labs team at [Sungard Availability\nServices][sungardas-url]\n\nGitHub: [https://sungardas.github.io][sungardas-github-url]\n\nBlog: [http://blog.sungardas.com/CTOLabs/][sungardaslabs-blog-url]\n\n[porper-image]: ./docs/images/logo.png?raw=true\n[convoy-ebs-url]: https://github.com/rancher/convoy/blob/master/docs/ebs.md\n[docker-zookeeper-url]: https://hub.docker.com/r/_/zookeeper\n[labs-github-url]: https://sungardas.github.io\n[labs-image]: https://raw.githubusercontent.com/SungardAS/repo-assets/master/images/logos/sungardas-labs-logo-small.png\n[sungardas-github-url]: https://sungardas.github.io\n[sungardas-url]: http://sungardas.com\n[sungardaslabs-blog-url]: http://blog.sungardas.com/CTOLabs/\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/AlexOugh/porper-core", "keywords": "serverless lambda permission", "license": "Free for non-commercial use", "maintainer": "", "maintainer_email": "", "name": "porper", "package_url": "https://pypi.org/project/porper/", "platform": "", "project_url": "https://pypi.org/project/porper/", "project_urls": { "Homepage": "https://github.com/AlexOugh/porper-core" }, "release_url": "https://pypi.org/project/porper/0.3.0/", "requires_dist": [ "boto3", "requests" ], "requires_python": "", "summary": "Portable Permission Controller", "version": "0.3.0" }, "last_serial": 3295590, "releases": { "0.1.2": [], "0.1.3": [ { "comment_text": "", "digests": { "md5": "6d36f42faf4dd104e01f7edf4c8cc4cf", "sha256": "4c2b7b6ae3077d80b6f6ac0772af2d4cfb6d8de00b8bf95518d83b04c3ddb527" }, "downloads": -1, "filename": "porper-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6d36f42faf4dd104e01f7edf4c8cc4cf", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 21208, "upload_time": "2016-09-22T15:49:07", "url": "https://files.pythonhosted.org/packages/a0/6a/126f26da87ed412df684c0b1c336c81f26aecb32e6c70cc7b6b3936fd69c/porper-0.1.3-py2.py3-none-any.whl" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "9663d0e38365ad07b824298de251e06b", "sha256": "5eefb5a0bef332665bb6fa9af7c18ead128b9f0e3cececea0e2a920cd410e330" }, "downloads": -1, "filename": "porper-0.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9663d0e38365ad07b824298de251e06b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 21216, "upload_time": "2016-09-30T17:15:42", "url": "https://files.pythonhosted.org/packages/e8/7e/5fa8261a0f5a08f521318b9ca8c7515ff175aa953d797c0c5ca72e1f63ce/porper-0.1.4-py2.py3-none-any.whl" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "ffb26f0c740521700d54d59b5e37235c", "sha256": "71518261b30ce429a5a474e15659721025fc7dc83ad37d88dd986dbbb57baa07" }, "downloads": -1, "filename": "porper-0.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ffb26f0c740521700d54d59b5e37235c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 23880, "upload_time": "2016-10-26T04:33:37", "url": "https://files.pythonhosted.org/packages/6b/7f/b205d6dfecad603d739f9c1c87362b8aca5a8de0d1421636ccd2d50b66d9/porper-0.1.5-py2.py3-none-any.whl" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "d6d16e601030a9b57aa6e89fb87dfb2b", "sha256": "7f17177867a8b469544832b091b7cdbd9fbda038cbfb093998ed5e4242b90048" }, "downloads": -1, "filename": "porper-0.1.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d6d16e601030a9b57aa6e89fb87dfb2b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 23990, "upload_time": "2016-11-22T03:10:39", "url": "https://files.pythonhosted.org/packages/cd/ea/1fd5458e05717149fb5931f4afecaa02fa56824e1cc474f3947b23eb661b/porper-0.1.6-py2.py3-none-any.whl" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "77b3c2c69952dbe939ae9a165f376b74", "sha256": "a466367fa519c7dcc6ed4f4a72430ca1dcd342b3b6b7946261eaf1c08a7baf7c" }, "downloads": -1, "filename": "porper-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "77b3c2c69952dbe939ae9a165f376b74", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 30323, "upload_time": "2017-08-06T03:31:40", "url": "https://files.pythonhosted.org/packages/73/d8/0ec5efc5d024f3cf2fb36c94aa601ccfe17b724c71075570bb89a02a8080/porper-0.2.0-py2.py3-none-any.whl" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "bdb6b997d50d7ff33056c63c65ac8fc4", "sha256": "f3cf08d29f475a35b06720b624c526f71c58671a4f834b6171a021f089d10f00" }, "downloads": -1, "filename": "porper-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bdb6b997d50d7ff33056c63c65ac8fc4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 33059, "upload_time": "2017-10-31T22:12:06", "url": "https://files.pythonhosted.org/packages/f2/cf/42ba50162216b0cef791f2df804fc77f5723999c2549adf931befa4ee665/porper-0.3.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bdb6b997d50d7ff33056c63c65ac8fc4", "sha256": "f3cf08d29f475a35b06720b624c526f71c58671a4f834b6171a021f089d10f00" }, "downloads": -1, "filename": "porper-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bdb6b997d50d7ff33056c63c65ac8fc4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 33059, "upload_time": "2017-10-31T22:12:06", "url": "https://files.pythonhosted.org/packages/f2/cf/42ba50162216b0cef791f2df804fc77f5723999c2549adf931befa4ee665/porper-0.3.0-py2.py3-none-any.whl" } ] }