{ "info": { "author": "Bakhtiyor Ruziev", "author_email": "bakhtiyor.ruziev@yandex.ru", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3.6" ], "description": ".. image:: https://img.shields.io/travis/com/bruziev/security_interface.svg?style=flat-square\n :target: https://travis-ci.com/bruziev/security_interface\n.. image:: https://img.shields.io/codecov/c/github/bruziev/security_interface.svg?style=flat-square\n :target: https://codecov.io/gh/bruziev/security_interface\n\n\nSecurity Interface\n==================\n\nThis library provides easy API for authentication and authorization.\n\nInstallation\n------------\n\nInstall with the following command::\n\n $ pip install security_interface\n\n\nUsage\n-----\n\nFirst of all you need implement ``IdentityPolicyInterface``\nand ``AuthorizationPolicyInterface`` interfaces. For example we can implement JWT Security::\n\n import jwt\n from security_interface import IdentityPolicyInterface, AuthorizationPolicyInterface\n\n class JwtIdentityPolicy(IdentityPolicyInterface):\n def __init__(self, secret, algorithm=\"HS256\"):\n self.algorithm = algorithm\n self.secret = secret\n\n async def identify(self, identity):\n if jwt is None:\n raise TypeError(\"Please install PyJWT\")\n try:\n return jwt.decode(\n identity,\n self.secret,\n algorithms=[self.algorithm],\n options={\"verify_exp\": True, \"verify_iat\": True},\n )\n except Exception as e:\n return None\n\n class JwtAuthPolicy(AuthorizationPolicyInterface):\n async def can(self, identity, permission):\n return permission in identity[\"scope\"]\n\n\nCreate security instance with our implementation\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n::\n\n from security_interface.api import Security\n jwt_identity = JwtIdentityPolicy(\"SECRET\")\n jwt_auth_policy = JwtAuthPolicy()\n security = Security(jwt_identity, jwt_auth_policy)\n # Checking claim\n security.identify(CLAIM)\n # Checking permission\n security.can(CLAIM, \"read\")\n security.can(CLAIM, \"write\")\n\nFor full implementation see `DEMO `_\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bruziev/security_interface", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "security-interface", "package_url": "https://pypi.org/project/security-interface/", "platform": "", "project_url": "https://pypi.org/project/security-interface/", "project_urls": { "Homepage": "https://github.com/bruziev/security_interface" }, "release_url": "https://pypi.org/project/security-interface/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "Security Interface for you project.", "version": "0.1.0" }, "last_serial": 4450939, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "abdb73d557c3fec7177a3af72aaaa84e", "sha256": "0d2f35a82fbea387898e316c504eed4689983f593adfd0b7767283c70e6b75ec" }, "downloads": -1, "filename": "security_interface-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "abdb73d557c3fec7177a3af72aaaa84e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5550, "upload_time": "2018-11-04T23:29:11", "url": "https://files.pythonhosted.org/packages/6e/ab/275e37f2a60422d9785de81c6104e776ddbde4e6d9cb34e4713c45690ddb/security_interface-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7e8006504c56d9f4cf906d71d72d8ce9", "sha256": "b3248553ac7f2c34ba1c135a17582ddbdc853c3a71e43a345a8ee52b18aca2b9" }, "downloads": -1, "filename": "security_interface-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7e8006504c56d9f4cf906d71d72d8ce9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3375, "upload_time": "2018-11-04T23:29:13", "url": "https://files.pythonhosted.org/packages/0b/d5/698447436c98bab0d3a3a401113b6ee0786060d099bac1bd2ad6ec6508c6/security_interface-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "abdb73d557c3fec7177a3af72aaaa84e", "sha256": "0d2f35a82fbea387898e316c504eed4689983f593adfd0b7767283c70e6b75ec" }, "downloads": -1, "filename": "security_interface-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "abdb73d557c3fec7177a3af72aaaa84e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5550, "upload_time": "2018-11-04T23:29:11", "url": "https://files.pythonhosted.org/packages/6e/ab/275e37f2a60422d9785de81c6104e776ddbde4e6d9cb34e4713c45690ddb/security_interface-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7e8006504c56d9f4cf906d71d72d8ce9", "sha256": "b3248553ac7f2c34ba1c135a17582ddbdc853c3a71e43a345a8ee52b18aca2b9" }, "downloads": -1, "filename": "security_interface-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7e8006504c56d9f4cf906d71d72d8ce9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3375, "upload_time": "2018-11-04T23:29:13", "url": "https://files.pythonhosted.org/packages/0b/d5/698447436c98bab0d3a3a401113b6ee0786060d099bac1bd2ad6ec6508c6/security_interface-0.1.0.tar.gz" } ] }