{ "info": { "author": "Curtis Maloney", "author_email": "curtis@tinbrain.net", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "Nap Token Auth\n==============\n\nSimple Token-based authentication.\n\nOverview\n--------\n\nA lot of people talk about having Token Auth for their REST APIs... but what does it actually mean? And what benefit is it?\n\nThe token is cryptographically signed chunk of data. In this case it contains the user ID, backend, and a timestamp of when it was issued.\n\nThis lets you generate and issue tokens to phone apps, services, etc, and not have to deal with logins, passwords, CSRF, etc.\n\nInstall\n-------\n\nAdd to settings.MIDDLEWARE, after the default authentication\nmiddleware:\n\n.. code-block:: python\n\n MIDDLEWARE = [\n 'django.middleware.security.SecurityMiddleware',\n 'django.contrib.sessions.middleware.SessionMiddleware',\n 'django.middleware.common.CommonMiddleware',\n 'django.middleware.csrf.CsrfViewMiddleware',\n 'django.contrib.auth.middleware.AuthenticationMiddleware',\n 'nap_token.middleware.NapTokenMiddleware',\n 'django.contrib.messages.middleware.MessageMiddleware',\n 'django.middleware.clickjacking.XFrameOptionsMiddleware',\n 'cloudselect.middleware.CORSDefeat',\n ]\n\n\nUsage\n-----\n\nWhen you want to log in a user, call `nap_token.get_auth_token(user)`, passing\na User instance returned from `django.contrib.auth.authenticate`.\n\nIt will return a signed, timestamped token. The client need only pass this in\na ``Authorization`` header, formatted as 'Bearer {token}', for the request to\nact as that user. If the token is absent, expired, or invalid, `requset.user`\nwill fall back to the normal Session Based Auth.\n\n\nIssuing Tokens\n--------------\n\nAs a quick and dirty example of how to issue tokens, here's an approach that\nwill issue a token for a user who can log in:\n\n.. code-block:: python\n\n from django.http import HttpResponse\n from django.contrib.auth.views import LoginView\n\n from nap_token import get_auth_token\n\n class TokenView(LoginView):\n\n def form_valid(self, form):\n user = form.get_user()\n return HttpResponse(get_auth_token(user))\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/funkybob/nap-token-auth/", "keywords": "django", "license": "", "maintainer": "", "maintainer_email": "", "name": "nap-token-auth", "package_url": "https://pypi.org/project/nap-token-auth/", "platform": "", "project_url": "https://pypi.org/project/nap-token-auth/", "project_urls": { "Homepage": "http://github.com/funkybob/nap-token-auth/" }, "release_url": "https://pypi.org/project/nap-token-auth/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "A Minimal Token-Based Auth for Django", "version": "0.1.2" }, "last_serial": 2978343, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "b922eb534aebd93afb5f1a4b5195d84d", "sha256": "6146caa42f8688ad1ac89b4770e3a941ca4828260155fb50c7cc07cbe7d86db6" }, "downloads": -1, "filename": "nap-token-auth-0.1.0.tar.gz", "has_sig": false, "md5_digest": "b922eb534aebd93afb5f1a4b5195d84d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2855, "upload_time": "2017-06-26T00:41:00", "url": "https://files.pythonhosted.org/packages/66/ec/60c430f9beca6f972d98a110af6e50638d8dca9f0c2b0bd6ca596d16f203/nap-token-auth-0.1.0.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "6f832e9a8d8cce9203a306fa86dae901", "sha256": "30a9899d53215156beb5a10d28fa61255a20576792fd1aa1ba4e79448e2e479d" }, "downloads": -1, "filename": "nap-token-auth-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6f832e9a8d8cce9203a306fa86dae901", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3069, "upload_time": "2017-06-26T01:52:27", "url": "https://files.pythonhosted.org/packages/3a/59/a9276eba5d7c3832d5086781207fd4dad07265cb396a27e56e8554408950/nap-token-auth-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6f832e9a8d8cce9203a306fa86dae901", "sha256": "30a9899d53215156beb5a10d28fa61255a20576792fd1aa1ba4e79448e2e479d" }, "downloads": -1, "filename": "nap-token-auth-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6f832e9a8d8cce9203a306fa86dae901", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3069, "upload_time": "2017-06-26T01:52:27", "url": "https://files.pythonhosted.org/packages/3a/59/a9276eba5d7c3832d5086781207fd4dad07265cb396a27e56e8554408950/nap-token-auth-0.1.2.tar.gz" } ] }