{"id":20793718,"url":"https://github.com/anexia/drf-multitokenauth","last_synced_at":"2025-05-05T23:43:37.621Z","repository":{"id":46224481,"uuid":"70126803","full_name":"anexia/drf-multitokenauth","owner":"anexia","description":"An extension to Django-Rest-Frameworks Token Authentication, enabling a user to have multiple authorization tokens","archived":false,"fork":false,"pushed_at":"2024-11-05T12:06:19.000Z","size":88,"stargazers_count":13,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-16T12:20:26.512Z","etag":null,"topics":["django","django-rest-framework","drf","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anexia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-06T05:55:08.000Z","updated_at":"2024-11-27T13:44:57.000Z","dependencies_parsed_at":"2024-11-17T16:21:12.521Z","dependency_job_id":null,"html_url":"https://github.com/anexia/drf-multitokenauth","commit_stats":{"total_commits":86,"total_committers":12,"mean_commits":7.166666666666667,"dds":0.5930232558139534,"last_synced_commit":"4553d203ffe658431092104ff90391d3d2b85d4b"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anexia%2Fdrf-multitokenauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anexia%2Fdrf-multitokenauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anexia%2Fdrf-multitokenauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anexia%2Fdrf-multitokenauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anexia","download_url":"https://codeload.github.com/anexia/drf-multitokenauth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252596322,"owners_count":21773842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-rest-framework","drf","hacktoberfest"],"created_at":"2024-11-17T16:11:09.531Z","updated_at":"2025-05-05T23:43:37.592Z","avatar_url":"https://github.com/anexia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Rest Multi Token Auth\n\n[![PyPI](https://img.shields.io/pypi/v/drf-multitokenauth)](https://pypi.org/project/drf-multitokenauth/)\n[![Test status](https://github.com/anexia/drf-multitokenauth/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/anexia/drf-multitokenauth/actions/workflows/test.yml)\n[![Codecov](https://img.shields.io/codecov/c/gh/anexia/drf-multitokenauth)](https://codecov.io/gh/anexia/drf-multitokenauth)\n\nThis django app is an extension for the Django Rest Framework.\nIt tries to overcome the limitation of Token Authentication, which only uses a single token per user. \n\n## How to use\n\nInstall:\n```bash\npip install drf-multitokenauth\n```\n\nAdd ``'drf_multitokenauth'`` to your ``INSTALLED_APPS`` in your Django settings file:\n```python\nINSTALLED_APPS = (\n    ...\n    'django.contrib.auth',\n    ...\n    'rest_framework',\n    ...\n    'drf_multitokenauth',\n    ...\n)\n\n```\n\nConfigure Django REST Framework to use ``'drf_multitokenauth.coreauthentication.MultiTokenAuthentication'``:\n```python\nREST_FRAMEWORK = {\n    ...\n    'DEFAULT_AUTHENTICATION_CLASSES': [\n        ...\n        'drf_multitokenauth.coreauthentication.MultiTokenAuthentication',\n        ...\n    ],\n    ...\n}\n```\n\n\nAnd add the auth urls to your Django url settings:\n```python\nfrom django.conf.urls import include\nfrom django.urls import re_path\n\n\nurlpatterns = [\n    ...\n    re_path(r'^api/auth/', include('drf_multitokenauth.urls', namespace='multi_token_auth')),\n    ...\n]    \n```\n\n\nThe following endpoints are provided:\n\n * `login` - takes username, password and an optional token_name; on success an auth token is returned\n * `logout`\n\n## Signals\n\n* ``pre_auth(username, password)`` - Fired when an authentication (login) is starting\n* ``post_auth(user)`` - Fired on successful auth\n\n## Tests\n\nSee folder [tests/](tests/). Basically, all endpoints are covered with multiple\nunit tests.\n\nFollow below instructions to run the tests.\nYou may exchange the installed Django and DRF versions according to your requirements. \n:warning: Depending on your local environment settings you might need to explicitly call `python3` instead of `python`.\n```bash\n# install dependencies\npython -m pip install --upgrade pip\npip install -r requirements.txt\n\n# setup environment\npip install -e .\npython setup.py install\n\n# run tests\ncd tests \u0026\u0026 python manage.py test\n```\n\n## Cache Backend\n\nIf you want to use a cache for the session store, you can install [django-memoize](https://pythonhosted.org/django-memoize/) and add `'memoize'` to `INSTALLED_APPS`.\n\nThen you need to use ``CachedMultiTokenAuthentication`` instead of ``MultiTokenAuthentication``.\n\n```bash\npip install django-memoize\n```\n\n## Django Compatibility Matrix\n\nIf your project uses an older verison of Django or Django Rest Framework, you can choose an older version of this project.\n\n| This Project | Python Version | Django Version | Django Rest Framework |\n|--------------|----------------|----------------|-----------------------|\n| 2.1.*        | 3.9+           | 4.2, 5.0, 5.1  | 3.15                  |\n| 2.0.*        | 3.7+           | 3.2, 4.0, 4.1  | 3.12, 3.13            |\n| 1.5.*        | 3.7+           | 3.2, 4.0, 4.1  | 3.12, 3.13            |\n| 1.4.*        | 3.6+           | 2.2, 3.2       | 3.9, 3.10, 3.11, 3.12 |\n| 1.3.*        | 2.7, 3.4+      | 1.11, 2.0      | 3.6, 3.7, 3.8         |\n| 1.2.*        | 2.7, 3.4+      | 1.8, 1.11, 2.0 | 3.6, 3.7, 3.8         |\n\nMake sure to use at least `DRF 3.10` when using `Django 3.0` or newer.\n\nReleases prior to `2.0.0` where published as [django-rest-multitokenauth](https://pypi.org/project/django-rest-multitokenauth/).\nNewer releases are published as [drf-multitokenauth](https://pypi.org/project/drf-multitokenauth/).\n\n## Migrating from 1.x to 2.x\n\n1. Uninstall `django-rest-multitokenauth`\n2. Install `drf-multitokenauth`\n3. Run the migration SQL bellow:\n    ```\n    ALTER TABLE django_rest_multitokenauth_multitoken RENAME to drf_multitokenauth_multitoken;\n    UPDATE django_migrations SET app = 'drf_multitokenauth' WHERE app = 'django_rest_multitokenauth';\n    UPDATE django_content_type SET app_label = 'drf_multitokenauth' WHERE app_label = 'django_rest_multitokenauth';\n    ```\n4. Run Django migrations\n\n## Changelog / Releases\n\nAll releases should be listed in the [releases tab on github](https://github.com/anexia/drf-multitokenauth/releases).\n\nSee [CHANGELOG.md](CHANGELOG.md) for a more detailed listing.\n\n\n## License\n\nThis project is published with the [BSD 3 Clause License](LICENSE). See [https://choosealicense.com/licenses/bsd-3-clause-clear/](https://choosealicense.com/licenses/bsd-3-clause-clear/) for more information about what this means.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanexia%2Fdrf-multitokenauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanexia%2Fdrf-multitokenauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanexia%2Fdrf-multitokenauth/lists"}