{ "info": { "author": "Gregory Mundy", "author_email": "greg@brighthive.io", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# BrightHive Auth Library\n\nAuthlib is a library built specifically for simplifying the task of adding authentication and authorization features to RESTful web services that reside within BrightHive Data Trusts. With this library, developers simply need to provision an OAuth 2.0 provider and inject it into a simple decorator to protect specific URLs.\n\n## Quick Links\n\n- [Read the docs](https://brighthive-authlib.readthedocs.io/en/latest/)\n\n## Features\n\n- Built-in Support for Auth0.\n- Simple decorator for injecting auth capabilities into applications.\n- Purpose-built for use with [Flask](http://flask.pocoo.org/) applications, however can be extended to other frameworks.\n\n## Installation\n\n### PyPi\n\n[Pypi](https://pypi.org) is the fastest method for installing this library. Simply install the `brighthive-authlib` package via the Pip installer. This library is intended for use with Python 3.5+.\n\n```bash\npip install brighthive-authlib\n```\n\n### Pipenv\n\nInstalling the library via [Pipenv](https://pipenv.readthedocs.io/en/latest/) is straightforward.\n\n```bash\npipenv install brighthive-authlib\n```\n\n### Dependencies\n\n- flask >= 1.0.2\n- pycryptodome >= 3.8.0\n- python-jose[pycryptodome] >= 3.0.1\n- requests >= 2.21.0\n\n## Usage\n\n### Auth0 Example\n\nThe code snippet shown below is a simple Flask application configured to use [Auth0](https://auth0.com) as the default OAuth 2.0 provider. Three steps are required to configure the library for use with a Flask application:\n\n1. Instantiate the OAuth 2.0 provider object.\n2. Decorate the route(s) to protect with the `token_required` decorator (passing the OAuth 2.0 provider object and optionally a dictionary of scopes).\n3. Configure the custom error handler to deal with `OAuth2ProviderError` exceptions (in this example, a 401 status is returned).\n4. Sit back and marvel at how painless the entire process is.\n\n```python\nimport json\nfrom flask import Flask, request\nfrom brighthive_authlib import OAuth2ProviderError, OAuth2ProviderFactory, AuthLibConfiguration, token_required\n\n\n# Warning: Testing purposes only. These attributes need to be protected.\nPROVIDER = 'AUTH0'\nOAUTH2_URL = 'https://brighthive-test.auth0.com'\nJSON_URL = '{}/.well-known/jwks.json'.format(OAUTH2_URL)\nAUDIENCE = 'http://localhost:8000'\nALGORITHMS = ['RS256']\n\n# Build the Auth Service Configuration Object\nauth_config = AuthLibConfiguration(\n provider=PROVIDER, base_url=OAUTH2_URL, jwks_url=JSON_URL, algorithms=ALGORITHMS, audience=AUDIENCE)\noauth2_provider = OAuth2ProviderFactory.get_provider(PROVIDER, auth_config)\n\n\n# Builed the Flask App\napp = Flask(__name__)\n\n# Add a Public Route\n@app.route('/public')\ndef public_resource():\n return json.dumps({'message': 'You can see me because I am public!'}), 200\n\n# Add a Private Route\n@app.route('/private')\n@token_required(oauth2_provider, ['get:users'])\ndef private_resource():\n return json.dumps({'message': 'If you can see me, you have a valid token.'}), 200\n\n# Error Handler for Invalid or Expired Tokens\n@app.errorhandler(OAuth2ProviderError)\ndef handle_auth_error(e):\n return json.dumps({'message': 'Access Denied'}), 401\n\n\nif __name__ == '__main__':\n app.run(debug=True)\n```\n\n## Contributing\n\nTo contribute code to this project, simply:\n\n1. Fork the repository from [here](https://github.com/brighthive/authlib).\n2. Write some code and associated unit tests.\n3. Create a pull request.\n\n## Setting up for Development\n\nTo set up a development environment, clone the repository and create a virtual environmemt with [Pipenv](https://docs.pipenv.org/).\n\n```bash\ngit clone git@github.com:brighthive/tpot-abacus-api.git\ncd tpot-abacus-api\npipenv --three\n```\n\nInstall Python dependencies.\n\n```bash\npipenv install\npipenv install --dev\n```\n\n## Testing\n\nThis project uses the excellent [pytest](https://docs.pytest.org/en/latest/) and [expects](https://github.com/jaimegildesagredo/expects) libraries for unit testing. All unit tests are housed in the `tests` module. To run unit tests, invoke `pytest` at the command prompt.\n\n```bash\n$ pytest\n\n======= test session starts =======\nplatform darwin -- Python 3.7.2, pytest-4.3.1, py-1.8.0, pluggy-0.9.0\nrootdir: /Users/gmundy/Work/brighthive-data-trusts/authlib, inifile: pytest.ini\nplugins: cov-2.6.1\ncollected 2 items\n\ntests/test_provider_factory.py .. [100%]\n\n=========== 2 passed in 0.60 seconds ===========\n```\n\n## License\n\n### The MIT License (MIT)\n\nCopyright \u00a9 `2019` `BrightHive`\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \u201cSoftware\u201d), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brighthive/authlib", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "brighthive-authlib", "package_url": "https://pypi.org/project/brighthive-authlib/", "platform": "", "project_url": "https://pypi.org/project/brighthive-authlib/", "project_urls": { "Homepage": "https://github.com/brighthive/authlib" }, "release_url": "https://pypi.org/project/brighthive-authlib/1.0.4/", "requires_dist": [ "flask", "pycryptodome", "python-jose[pycryptodome]", "requests" ], "requires_python": "", "summary": "BrightHive API Authorization and Authentication Library", "version": "1.0.4" }, "last_serial": 5220174, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "5da56d4a0e44bffbdb5f272c77e94316", "sha256": "73e6058259f8693e52348e43e5fe107269a143630fb29909d108d57b9d76971c" }, "downloads": -1, "filename": "brighthive_authlib-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5da56d4a0e44bffbdb5f272c77e94316", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10050, "upload_time": "2019-03-22T06:35:37", "url": "https://files.pythonhosted.org/packages/d5/8a/dc4e199eb517cd08ed6df3cd063690a34fb0bb25be0425fe7f970aa7665b/brighthive_authlib-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6c49066e41c7d91aa0af20db5ef19ef5", "sha256": "33aa3d64a4f3489b51757159e1ad1b1ca3c9a65a82f780988a8b132f0006f9db" }, "downloads": -1, "filename": "brighthive-authlib-1.0.0.tar.gz", "has_sig": false, "md5_digest": "6c49066e41c7d91aa0af20db5ef19ef5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5011, "upload_time": "2019-03-22T06:35:39", "url": "https://files.pythonhosted.org/packages/6b/6e/3456d13ecf4a15fe74fc6d657cfb903d00069c4723319763280d6472317c/brighthive-authlib-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "22900e954eaf4717e7a786f89adcc03c", "sha256": "3852f40d34c0014aabc066f11f3ce0169b712ff8829d7155ff114ae2fdd50847" }, "downloads": -1, "filename": "brighthive_authlib-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "22900e954eaf4717e7a786f89adcc03c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10060, "upload_time": "2019-03-29T02:04:47", "url": "https://files.pythonhosted.org/packages/86/0c/6f75dfe77aeffbc8ac7aaba3c4fb682c752aff04a149b464f90efed05ce8/brighthive_authlib-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7bae938144aa28b9fe9092038df89649", "sha256": "94237485a1e46deb00a095bb255bd29369a6dac8932f734e918ab248dec9d5e8" }, "downloads": -1, "filename": "brighthive-authlib-1.0.1.tar.gz", "has_sig": false, "md5_digest": "7bae938144aa28b9fe9092038df89649", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5022, "upload_time": "2019-03-29T02:04:49", "url": "https://files.pythonhosted.org/packages/55/45/e140775b71e8283d4f327aa048c199caa010c2f192464261cbd2b7addd04/brighthive-authlib-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "ba2c86d6a13141196ae2850a8ff92248", "sha256": "20e0f8b87b88bbee6f2d61d0598a1c0ac478067bc956f9bafb9bd67c81630566" }, "downloads": -1, "filename": "brighthive_authlib-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "ba2c86d6a13141196ae2850a8ff92248", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12412, "upload_time": "2019-03-29T22:11:12", "url": "https://files.pythonhosted.org/packages/c6/49/7d5baeb050f4c55c2ca4061a3d91fa775508221e46876f2c4039c8c45e5f/brighthive_authlib-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "946f2ca5092dcf57ed4499d2379591a4", "sha256": "f6dd1c2c5944335b43830189dbfcae2755cc4a6ab05f730c414e3e21ab15d142" }, "downloads": -1, "filename": "brighthive-authlib-1.0.2.tar.gz", "has_sig": false, "md5_digest": "946f2ca5092dcf57ed4499d2379591a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8281, "upload_time": "2019-03-29T22:11:13", "url": "https://files.pythonhosted.org/packages/c4/ba/f4095fbae5a2cc3458543f14eb70e0b7216d592f0d77fc8050c3113568f7/brighthive-authlib-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "6d504940f8073e51ecbbbb1df9d75463", "sha256": "181842c665cceecfa8d501b3ac361c03ce0ac187678d2974225fbbf98a09b3ba" }, "downloads": -1, "filename": "brighthive_authlib-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "6d504940f8073e51ecbbbb1df9d75463", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12421, "upload_time": "2019-04-12T02:49:28", "url": "https://files.pythonhosted.org/packages/0a/10/ec73eeacad9f39cccd550331cb15d134c3223723d51c5d7fa0c1cf88d34e/brighthive_authlib-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c9917f0e91e28ab8c4410b162f7466ad", "sha256": "a19db21374736ed4ba58dfac1adfabbc2551f11fd1cd40d810ded7805205ee7c" }, "downloads": -1, "filename": "brighthive-authlib-1.0.3.tar.gz", "has_sig": false, "md5_digest": "c9917f0e91e28ab8c4410b162f7466ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8306, "upload_time": "2019-04-12T02:49:29", "url": "https://files.pythonhosted.org/packages/52/8e/0ded3207d6ada8c0091a0f1208dc3f58a4603d9950d6b3e686c87a7814c3/brighthive-authlib-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "d65e7b1c58592d3adbbff38a076c74e4", "sha256": "43c5057d904c71a940b94245a624d3b5934c180a586facd49eb09320b450e130" }, "downloads": -1, "filename": "brighthive_authlib-1.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "d65e7b1c58592d3adbbff38a076c74e4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12438, "upload_time": "2019-05-03T03:32:12", "url": "https://files.pythonhosted.org/packages/de/8b/62785c06f7c75ed364aedebe13a575d2b8d2f02eb9574abc8c38c9a8968b/brighthive_authlib-1.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "840f06cc592d97146cd9fc6085208fe0", "sha256": "b821e81eece6a7aa60e19cd424d013c5e740e1c29c0d5cebd6843b0db066e080" }, "downloads": -1, "filename": "brighthive-authlib-1.0.4.tar.gz", "has_sig": false, "md5_digest": "840f06cc592d97146cd9fc6085208fe0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8312, "upload_time": "2019-05-03T03:32:15", "url": "https://files.pythonhosted.org/packages/54/41/3bfdab5e5294005059bed6611c656f9d49956ce6c16a328144de44c88d9b/brighthive-authlib-1.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d65e7b1c58592d3adbbff38a076c74e4", "sha256": "43c5057d904c71a940b94245a624d3b5934c180a586facd49eb09320b450e130" }, "downloads": -1, "filename": "brighthive_authlib-1.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "d65e7b1c58592d3adbbff38a076c74e4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12438, "upload_time": "2019-05-03T03:32:12", "url": "https://files.pythonhosted.org/packages/de/8b/62785c06f7c75ed364aedebe13a575d2b8d2f02eb9574abc8c38c9a8968b/brighthive_authlib-1.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "840f06cc592d97146cd9fc6085208fe0", "sha256": "b821e81eece6a7aa60e19cd424d013c5e740e1c29c0d5cebd6843b0db066e080" }, "downloads": -1, "filename": "brighthive-authlib-1.0.4.tar.gz", "has_sig": false, "md5_digest": "840f06cc592d97146cd9fc6085208fe0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8312, "upload_time": "2019-05-03T03:32:15", "url": "https://files.pythonhosted.org/packages/54/41/3bfdab5e5294005059bed6611c656f9d49956ce6c16a328144de44c88d9b/brighthive-authlib-1.0.4.tar.gz" } ] }