{ "info": { "author": "Michal Proszek", "author_email": "poxip@arabel.la", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP" ], "description": "===============\ndrf-jwt-devices\n===============\n|travis|_ |pypi|_ |coveralls|_ |requiresio|_\n\nPermanent token feature for `Django Rest Framework JWT `_\n\nBy default JWT tokens have short lifetime because of security reasons, but sometimes you may want to keep user logged\nin, without the need to refresh the auth token each 5 minutes. For this case, you should consider using the permanent\ntoken authentication.\n\nInstallation\n============\nTo use, add ``jwt_devices`` to your ``INSTALLED_APPS``, and then migrate the project.\n\nConfiguration\n-------------\n\nTo enable permanent token authentication, update rest framework's default authentication classes list:\n\n.. code-block:: python\n\n REST_FRAMEWORK={\n \"DEFAULT_AUTHENTICATION_CLASSES\": [\n \"jwt_devices.authentication.PermanentTokenAuthentication\"\n ]\n }\n\nAnother step is to add a few urls to your url patterns, and register the ``DeviceViewSet``:\n\n.. code-block:: python\n\n from jwt_devices import views\n from rest_framework.routers import DefaultRouter\n\n router = DefaultRouter()\n router.register(r'devices', views.DeviceViewSet)\n \n urlpatterns = [\n # ...\n url(r'^device-refresh-token/$', views.device_refresh_token),\n url(r'^device-logout/$', views.device_logout)\n ] + router.urls\n\n\nUsing the API views\n-------------------\n\n**Login & logout view**\n\nWhen using the regular JWT login or the device logout view, use the ``X-Device-Model`` header to pass device model\n(otherwise, user agent will used instead as the name). After a successful login, the permanent token and id of the\ncreated device will be returned, for example:\n\n.. code-block:: javascript\n\n {\n \"token\": \"ads344fdgfd5454yJ0eAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VynRlYW1AYXJhYmVsLmxh\",\n \"permanent_token\": \"gfd5454yJ0eAiOiJKV1QiLCJhbGciOiJ\",\n \"device_id\": 1\n }\n\nThe ``device_id`` is used to logout the device, so it should be saved on the front-end side (in local storage, for\nexample).\n\nTo logout a device, make a **DELETE** request to the ``rest_framework_jwt.views.device_logout`` view, passing device's\nid in the ``Device-Id`` header to identify the device.\n\n**Refresh JWT token using permanent token**\n\nTo refresh JWT token, you have to pass the ``Permanent-Token`` header along with the request to identify the device.\nOn success, response will return new JWT token (the same as it does after login).\n\nIn case the permanent token has expired, the device will be logged out, and it will require login in again to obtain a\nnew permanent token. To customize the expiration time and expiration accuracy, set the following settings in your\n``REST_FRAMEWORK`` configuration in **settings.py**\n\n\n**PermittedHeadersMiddleware**\n\nAs you may know, the content of a permanent token is a very fragile information, which should be sent along with a\nrequest only when it is needed. To avoid situations in which a front-end developer has incorrectly implemented the\npermanent token authentication on the front-end side and the permanent token value is sent with all requests\n(just like the JWT token), the ``jwt_devices.middleware.PermittedHeadersMiddleware`` comes in handy. The middleware looks\nfor ``Permanent-Token`` in the headers, and checks if the view is not the\n``jwt_devices.views.DeviceRefreshJSONWebToken`` in which the ``Permanent-Token`` header is obligatory, otherwise it\nreturns a **400 Bad Request** error.\n\nTo use the ``jwt_devices.middleware.PermittedHeadersMiddleware`` in your application, add\n``jwt_devices.middleware.jwt_devices.middleware.PermittedHeadersMiddleware`` to your ``MIDDLEWARES`` or\n``MIDDLEWARE_CLASSES`` (in Django <1.10) in Django settings.\n\n**Settings**\n\n* ``JWT_PERMANENT_TOKEN_AUTH`` - option to enable/disable the permanent token authentication (default: ``True``)\n* ``JWT_PERMANENT_TOKEN_EXPIRATION_DELTA`` - describes how long can the permanent token live\n (default: ``datetime.timedelta(days=7)``)\n* ``JWT_PERMANENT_TOKEN_EXPIRATION_ACCURACY`` - the accuracy of updating permanent token last request time to decrease\n the number of database queries (default: ``datetime.timedelta(minutes=30)``)\n\nSupport\n=======\n* Django 1.8 - 1.11\n* Django Rest Framework 3.1 - 3.8\n* Python 3.4 - 3.6\n\n.. |travis| image:: https://secure.travis-ci.org/ArabellaTech/drf-jwt-devices.svg?branch=master\n.. _travis: http://travis-ci.org/ArabellaTech/drf-jwt-devices\n\n.. |pypi| image:: https://img.shields.io/pypi/v/drf-jwt-devices.svg\n.. _pypi: https://pypi.python.org/pypi/drf-jwt-devices\n\n.. |coveralls| image:: https://coveralls.io/repos/github/ArabellaTech/drf-jwt-devices/badge.svg?branch=master\n.. _coveralls: https://coveralls.io/github/ArabellaTech/drf-jwt-devices\n\n.. |requiresio| image:: https://requires.io/github/ArabellaTech/drf-jwt-devices/requirements.svg?branch=master\n.. _requiresio: https://requires.io/github/ArabellaTech/drf-jwt-devices/requirements/", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ArabellaTech/drf-jwt-devices", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "drf-jwt-devices", "package_url": "https://pypi.org/project/drf-jwt-devices/", "platform": "", "project_url": "https://pypi.org/project/drf-jwt-devices/", "project_urls": { "Homepage": "https://github.com/ArabellaTech/drf-jwt-devices" }, "release_url": "https://pypi.org/project/drf-jwt-devices/1.2.2/", "requires_dist": null, "requires_python": "", "summary": "Permanent token authentication for django-rest-framework-jwt", "version": "1.2.2" }, "last_serial": 5804243, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "9e2f9ad0e4a79edad36357078e8aca35", "sha256": "2f1ff6a352b3cdf6f8c40e8797465e63264d950ebbfc188edd135ee1e2f78339" }, "downloads": -1, "filename": "drf_jwt_devices-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9e2f9ad0e4a79edad36357078e8aca35", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 26138, "upload_time": "2017-08-04T13:25:16", "url": "https://files.pythonhosted.org/packages/49/e6/bb379fc97c3228bb4256d3b5c895fe437888d6a1df587be801eeac8e543e/drf_jwt_devices-1.0.0-py2.py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "4d3f20a73451749ba09ccccbc1517de1", "sha256": "28d64c6ad18088b07a49224cc31a606db90e7b0958a158bb69d14797daf7cd0d" }, "downloads": -1, "filename": "drf_jwt_devices-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4d3f20a73451749ba09ccccbc1517de1", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 39305, "upload_time": "2017-08-14T11:31:18", "url": "https://files.pythonhosted.org/packages/09/f5/dd3f7af92b4eb332fb10d91c16b87f05274340d1e5f523b4e8971814bb4b/drf_jwt_devices-1.1.0-py2.py3-none-any.whl" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "4ffd8f4b3a2a3305e4bcd2d9bb935268", "sha256": "ca60cc55e8c66358bb6aef9133d48ccd9102577c222aaeb7d8ed278ae7cad9dd" }, "downloads": -1, "filename": "drf_jwt_devices-1.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4ffd8f4b3a2a3305e4bcd2d9bb935268", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 24165, "upload_time": "2018-07-12T16:27:01", "url": "https://files.pythonhosted.org/packages/a3/cb/550805f54ee2dc31a38011f263758932cf9fd1f102bfa539ff1dfaaf2ff9/drf_jwt_devices-1.2.0-py2.py3-none-any.whl" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "96e6f884a2302558f903ffd6dce06691", "sha256": "61a4d5bde6d8234ac8279910468a9e7077b26bb5f8927049594b27a5ee781055" }, "downloads": -1, "filename": "drf_jwt_devices-1.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "96e6f884a2302558f903ffd6dce06691", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 24182, "upload_time": "2018-09-26T17:21:33", "url": "https://files.pythonhosted.org/packages/21/5b/9934c5531ebc76b0a726ba6635045abc53488235a0fcf2cf7311187d191c/drf_jwt_devices-1.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "861f2030011fc7ad3763b7889608256c", "sha256": "f13ac4a017b4938ae5ccbd6423c497a85544c64bbfba060a9d220c78985ff472" }, "downloads": -1, "filename": "drf-jwt-devices-1.2.1.tar.gz", "has_sig": false, "md5_digest": "861f2030011fc7ad3763b7889608256c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11597, "upload_time": "2018-10-25T22:12:54", "url": "https://files.pythonhosted.org/packages/55/75/68434db21a53f5df962d66f569db5460f74a51fb25e23d1e85a56f9ec1c2/drf-jwt-devices-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "2455431fa2d57badc6f7286d0a47510b", "sha256": "db085b77d67344ecab1d3a45ed2690c85b6c234745c7f8fcdf28da9fcf570e96" }, "downloads": -1, "filename": "drf-jwt-devices-1.2.2.tar.gz", "has_sig": false, "md5_digest": "2455431fa2d57badc6f7286d0a47510b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9816, "upload_time": "2019-09-09T15:46:20", "url": "https://files.pythonhosted.org/packages/80/01/5522381025f4964c31bd048dbf0e4836c160d34e2e6416f9de3d1275e948/drf-jwt-devices-1.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2455431fa2d57badc6f7286d0a47510b", "sha256": "db085b77d67344ecab1d3a45ed2690c85b6c234745c7f8fcdf28da9fcf570e96" }, "downloads": -1, "filename": "drf-jwt-devices-1.2.2.tar.gz", "has_sig": false, "md5_digest": "2455431fa2d57badc6f7286d0a47510b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9816, "upload_time": "2019-09-09T15:46:20", "url": "https://files.pythonhosted.org/packages/80/01/5522381025f4964c31bd048dbf0e4836c160d34e2e6416f9de3d1275e948/drf-jwt-devices-1.2.2.tar.gz" } ] }