{ "info": { "author": "Bastian Meyer", "author_email": "bastian@bastianmeyer.eu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Flask", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Internet", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Flask-EasyJWT\n\n\n[![PyPI](https://img.shields.io/pypi/v/flask-easyjwt.svg)](https://pypi.org/project/flask-easyjwt/)\n[![PyPI - License](https://img.shields.io/pypi/l/flask-easyjwt.svg)](https://github.com/BMeu/Flask-EasyJWT/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/BMeu/Flask-EasyJWT.svg?branch=master)](https://travis-ci.org/BMeu/Flask-EasyJWT)\n[![codecov](https://codecov.io/gh/BMeu/Flask-EasyJWT/branch/master/graph/badge.svg)](https://codecov.io/gh/BMeu/Flask-EasyJWT)\n[![Documentation Status](https://readthedocs.org/projects/flask-easyjwt/badge/?version=latest)](https://flask-easyjwt.readthedocs.io/en/latest/?badge=latest)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flask-easyjwt.svg)\n\nFlask-EasyJWT provides a simple interface to creating and verifying\n[JSON Web Tokens (JWTs)](https://tools.ietf.org/html/rfc7519) in Python. It allows you to once define the claims of the\nJWT, and to then create and accept tokens with these claims without having to check if all the required data is given\nor if the token actually is the one you expect.\n\nFlask-EasyJWT is a simple wrapper around [EasyJWT](https://github.com/BMeu/EasyJWT) for easy usage in\n[Flask](http://flask.pocoo.org/) applications. It provides configuration options via Flask's application configuration\nfor common settings of all tokens created in a web application. For detailed information on how to use\n[EasyJWT](https://github.com/BMeu/EasyJWT), see [its documentation](https://easyjwt.readthedocs.org/en/latest/).\n\n```python\nfrom flask_easyjwt import FlaskEasyJWT\nfrom flask import Flask\n\n# Define the claims of your token.\nclass MySuperSimpleJWT(FlaskEasyJWT):\n\n def __init__(self, key):\n super().__init__(key)\n\n # Define a claim `name`.\n self.name = None\n\n# Define the default configuration options for FlaskEasyJWT\n# in the configuration of your Flask app.\napp = Flask(__name__)\napp.config.from_mapping(\n # The default key for encoding and decoding tokens.\n EASYJWT_KEY='Super secret key',\n\n # Tokens will be valid for 15 minutes after creation by default.\n EASYJWT_TOKEN_VALIDITY=15 * 60\n)\n\n@app.route('/token/')\ndef get_token(name):\n \"\"\" This view returns a token with the given name as its value. \"\"\"\n token_object = MySuperSimpleJWT()\n token_object.name = name\n return token_object.create()\n\n@app.route('/verify/')\ndef verify_token(token):\n \"\"\" This view verifies the given token and returns the contained name. \"\"\"\n verified_token_object = MySuperSimpleJWT.verify(token)\n return verified_token_object.name\n```\n\n## Features\n\n * Integrates [EasyJWT](https://github.com/BMeu/EasyJWT) into Flask for easy configuration of default options for\n creating and verifying JWTs.\n * Define the claims of your token once as a class, then use this class to easily create and verify multiple tokens.\n * No worries about typos in dictionary keys: the definition of your claim set as a class enables IDEs to find those\n typos for you.\n * Multiple tokens may have the same claims, but different intentions. Flask-EasyJWT will take care of this for you: you\n can define a token for account validation and one for account deletion, both with the account ID as a claim, and you\n don't need to worry about accidentally deleting a newly created account instead of validating it, just because\n someone mixed up the tokens.\n * All registered JWT claims are supported: `aud`, `exp`, `iat`, `iss`, `jti`, `nbf`, and `sub`.\n\nFor a full list of features, see [the features of EasyJWT](https://easyjwt.readthedocs.org/en/latest/#features).\n\n## System Requirements & Installation\n\nFlask-EasyJWT requires Python 3.6 or newer.\n\nFlask-EasyJWT is available [on PyPI](https://pypi.org/project/flask-easyjwt/). You can install it using your favorite\npackage manager.\n\n * PIP:\n\n ```bash\n python -m pip install flask_easyjwt\n ```\n\n * Pipenv:\n\n ```bash\n pipenv install flask_easyjwt\n ```\n\n## Usage\n\nFlask-EasyJWT is used exactly as [EasyJWT](https://github.com/BMeu/EasyJWT). Therefore, this section only describes the\nspecific features of Flask-EasyJWT and the basic usage. For detailed explanations on how to use EasyJWT (for example,\noptional claims, registered claims such as `aud`, `iat`, and `sub`, or verifying third-party tokens), see\n[its documentation](https://easyjwt.readthedocs.org/en/latest/#usage).\n\n### Application Setup\n\nYou do not need to initialize Flask-EasyJWT with your Flask application. All you have to do (although even this is,\nstrictly speaking, not required), is to specify some default settings for all of your tokens in the configuration of\nyour Flask application. These settings are:\n\n\n| Configuration Key | Description |\n|--------------------------|-------------|\n| `EASYJWT_KEY` | The key that will be used for encoding and decoding all tokens. If `EASYJWT_KEY` is not specified, Flask-EasyJWT will fall back to Flask's `SECRET_KEY` configuration value. |\n| `EASYJWT_TOKEN_VALIDITY` | The validity of each token after its creation. This value can be given as a string (that is parsable to an integer), an integer, or a `timedelta` object. The former two are interpreted in seconds. |\n\nYou can specify these configuration values as any other configuration values in your Flask application, for example,\nusing a mapping in your code:\n\n```python\nfrom datetime import timedelta\nfrom flask import Flask\n\napp = Flask(__name__)\napp.config.update(\n EASYJWT_KEY='Super secret key',\n EASYJWT_TOKEN_VALIDITY=timedelta(minutes=7)\n)\n```\n\nIn this example, all tokens will (by default) be encoded using the (not so secure) string `Super secret key` and will\nbe valid for seven minutes after they have been created (i.e., after the `create()` method has been called on the token\nobject).\n\nOf course, any other way of specifying the configuration values will work as well (see\n[Flask's documentation](https://flask.palletsprojects.com/en/1.1.x/config/)).\n\n### Token Specification & Usage\n\nTokens are specified and used exactly as with [EasyJWT](https://easyjwt.readthedocs.org/en/latest/#usage):\n\n```python\nfrom flask_easyjwt import FlaskEasyJWT\n\n# Define the claims of your token.\nclass MySuperSimpleJWT(FlaskEasyJWT):\n\n def __init__(self, key):\n super().__init__(key)\n\n # Define a claim `name`.\n self.name = None\n\n# Assuming we are within a Flask app context. \n\n# Create a token with some values.\ntoken_object = MySuperSimpleJWT()\ntoken_object.name = 'Zaphod Beeblebrox'\ntoken = token_object.create()\n\n# Verify the created token.\nverified_token_object = MySuperSimpleJWT.verify(token)\nassert verified_token_object.name == 'Zaphod Beeblebrox'\n```\n\nThe only difference is that you do not have to pass the key for encoding or decoding the token to the constructor and\n`verify()` method, respectively (you still can do so if you do not want to use the default key defined in your\napplication's configuration).\n\nAdditionally, if the configuration value `EASYJWT_TOKEN_VALIDITY` is set, the token will\nbe valid for the amount specified in this configuration value after it has been created with `create()`. If this\nconfiguration value is not set tokens will not expire. If you explicitly set the expiration date on a token object\nthis value will always take precedence (if it is not `None`):\n\n```python\nimport datetime\n\nfrom flask_easyjwt import FlaskEasyJWT\nfrom flask import Flask\n\n# Define the claims of your token.\nclass MySuperSimpleJWT(FlaskEasyJWT):\n\n def __init__(self, key):\n super().__init__(key)\n\n # Define a claim `name`.\n self.name = None\n\n# Define the default configuration options for FlaskEasyJWT\n# in the configuration of your Flask app.\napp = Flask(__name__)\napp.config.from_mapping(\n EASYJWT_KEY='Super secret key',\n EASYJWT_TOKEN_VALIDITY=datetime.timedelta(minutes=7)\n)\n\n# Assuming we are within a Flask app context.\n\ntoken_object = MySuperSimpleJWT()\ntoken_object.name = 'Zaphod Beeblebrox'\n\n# This token will expire in 15 minutes, even though the default token validity is set to 7 minutes.\ntoken_object.expiration_date = datetime.datetime.utcnow() + datetime.timedelta(minutes=15)\n```\n\nInitializing token objects and creating and verifying tokens must be executed within a\n[Flask application context](https://flask.palletsprojects.com/en/1.1.x/appcontext/) if you want to use the configuration\nvalues from the application's configuration.\n\n## Acknowledgements\n\nFlask-EasyJWT is just an easy-to-use abstraction layer around Jos\u00e9 Padilla's\n[PyJWT library](https://pypi.org/project/PyJWT/) that does the actual work of creating and verifying the tokens\naccording to the JWT specification. Without his work, Flask-EasyJWT would not be possible.\n\n## License\n\nFlask-EasyJWT is developed by [Bastian Meyer](https://www.bastianmeyer.eu)\n<[bastian@bastianmeyer.eu](mailto:bastian@bastianmeyer.eu)> and is licensed under the\n[MIT License]((http://www.opensource.org/licenses/MIT)). For details, see the attached [LICENSE](LICENSE) file. \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/BMeu/Flask-EasyJWT", "keywords": "jwt token tokens JSON Flask", "license": "", "maintainer": "", "maintainer_email": "", "name": "flask-easyjwt", "package_url": "https://pypi.org/project/flask-easyjwt/", "platform": "any", "project_url": "https://pypi.org/project/flask-easyjwt/", "project_urls": { "Documentation": "https://flask-easyjwt.readthedocs.io/en/latest/", "Homepage": "https://github.com/BMeu/Flask-EasyJWT", "Source": "https://github.com/BMeu/Flask-EasyJWT", "Tracker": "https://github.com/BMeu/Flask-EasyJWT/issues" }, "release_url": "https://pypi.org/project/flask-easyjwt/0.2.0/", "requires_dist": [ "easyjwt (==0.1.*)", "Flask (>=1.0)" ], "requires_python": ">=3.6", "summary": "Super simple JSON Web Tokens for Flask", "version": "0.2.0" }, "last_serial": 5907168, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "353a939377bd36467c4e6d92bea3b8ea", "sha256": "a740a1e9a40b23175101a3058c11e3649729ce5a46b0f4e80b9304958fc25b25" }, "downloads": -1, "filename": "flask_easyjwt-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "353a939377bd36467c4e6d92bea3b8ea", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 9061, "upload_time": "2019-09-29T13:47:59", "url": "https://files.pythonhosted.org/packages/0f/de/a853b8719972dcc46c3136051b54d939f8b938293208b906e3c618ee63f7/flask_easyjwt-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5fda4c8317fb06cd611de4a2922cb66f", "sha256": "e59c258ad0093b66c4c0f079fbd6092ee3362fdab408a21a97efb061c5b888ea" }, "downloads": -1, "filename": "flask_easyjwt-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5fda4c8317fb06cd611de4a2922cb66f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 7967, "upload_time": "2019-09-29T13:48:05", "url": "https://files.pythonhosted.org/packages/66/34/dea15e975686c21c5db0228aa9a6db740507ee70ed818e27ed3ed238a142/flask_easyjwt-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "54293c5eeecf16f19ff9a4e6af831352", "sha256": "01eec3f49b4dd9ecad9de6a8cfe22b74334b48ddf08e23e588721f91d06faaf4" }, "downloads": -1, "filename": "flask_easyjwt-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "54293c5eeecf16f19ff9a4e6af831352", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 9143, "upload_time": "2019-09-30T14:27:06", "url": "https://files.pythonhosted.org/packages/2e/e7/f623e424235149f154194be83bcc815e80a9f1b1b983bb59f467a1138d20/flask_easyjwt-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4059b4516f58ee447b823fdf4048c4e4", "sha256": "85a9a20e15e73861ceb2d81ac73b71049400d09996f54745ea74aeed3fe8cd11" }, "downloads": -1, "filename": "flask_easyjwt-0.2.0.tar.gz", "has_sig": false, "md5_digest": "4059b4516f58ee447b823fdf4048c4e4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8037, "upload_time": "2019-09-30T14:27:17", "url": "https://files.pythonhosted.org/packages/80/e7/fe36ee879e67b62fee0acd611645b3108276804b8efe230a7b011fb64604/flask_easyjwt-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "54293c5eeecf16f19ff9a4e6af831352", "sha256": "01eec3f49b4dd9ecad9de6a8cfe22b74334b48ddf08e23e588721f91d06faaf4" }, "downloads": -1, "filename": "flask_easyjwt-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "54293c5eeecf16f19ff9a4e6af831352", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 9143, "upload_time": "2019-09-30T14:27:06", "url": "https://files.pythonhosted.org/packages/2e/e7/f623e424235149f154194be83bcc815e80a9f1b1b983bb59f467a1138d20/flask_easyjwt-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4059b4516f58ee447b823fdf4048c4e4", "sha256": "85a9a20e15e73861ceb2d81ac73b71049400d09996f54745ea74aeed3fe8cd11" }, "downloads": -1, "filename": "flask_easyjwt-0.2.0.tar.gz", "has_sig": false, "md5_digest": "4059b4516f58ee447b823fdf4048c4e4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8037, "upload_time": "2019-09-30T14:27:17", "url": "https://files.pythonhosted.org/packages/80/e7/fe36ee879e67b62fee0acd611645b3108276804b8efe230a7b011fb64604/flask_easyjwt-0.2.0.tar.gz" } ] }