All Projects → anexia-it → django-rest-multitokenauth

anexia-it / django-rest-multitokenauth

Licence: BSD-3-Clause license
An extension to Django-Rest-Frameworks Token Authentication, enabling a user to have multiple authorization tokens

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to django-rest-multitokenauth

drf-registration
Simple user registration package based on Django Rest Framework. DRF Registration - The easy way to generate registration RESTful APIs
Stars: ✭ 32 (+146.15%)
Mutual labels:  django-rest-framework, drf
django-rest-framework-recaptcha
reCAPTCHA field for Django REST framework serializers
Stars: ✭ 24 (+84.62%)
Mutual labels:  django-rest-framework, drf
django-rest-framework-datatables-editor
Seamless integration between Django REST framework, Datatables and Datatables Editor.
Stars: ✭ 25 (+92.31%)
Mutual labels:  django-rest-framework, drf
drf-angular-docker-tutorial
Dockerized Django Back-end API using DRF with Angular Front-end Tutorial
Stars: ✭ 53 (+307.69%)
Mutual labels:  django-rest-framework, drf
django-ninja-extra
Django Ninja Extra - Class-Based Utility and more for Django Ninja(Fast Django REST framework)
Stars: ✭ 53 (+307.69%)
Mutual labels:  django-rest-framework, drf
evcloud
EVCloud是一个基于ceph和libvirt的轻量级云主机管理平台,实用稳定,维护简易
Stars: ✭ 44 (+238.46%)
Mutual labels:  django-rest-framework
ChRIS ultron backEnd
Backend for ChRIS
Stars: ✭ 28 (+115.38%)
Mutual labels:  django-rest-framework
web-ui
python+selenium+pytest+allure UI 自动化框架
Stars: ✭ 199 (+1430.77%)
Mutual labels:  django-rest-framework
django-on-k8s
An end to end tutorial to run a Django Web Application having a PostgreSQL database in Kubernetes
Stars: ✭ 37 (+184.62%)
Mutual labels:  django-rest-framework
Cetus-GUI
cetus web端管理工具
Stars: ✭ 53 (+307.69%)
Mutual labels:  django-rest-framework
Dailyfresh-B2C
这是一个 ☛全栈/全端/全平台☚ 的B2C模式的电商项目, web后台基于Django2.0 + Python3.6, 前后端分离,前端使用Vue框架开发。移动端基于Flutter开发,一套代码支持Android&IOS平台。微信小程序基于mpvue框架开发。
Stars: ✭ 74 (+469.23%)
Mutual labels:  django-rest-framework
DRF-API-Logger
An API Logger for your Django Rest Framework project.
Stars: ✭ 184 (+1315.38%)
Mutual labels:  django-rest-framework
QuestionTime
📚 Quora-like Single Page Application built with Django, Django REST Framework and Vue JS
Stars: ✭ 76 (+484.62%)
Mutual labels:  django-rest-framework
deploy-django
A bash script to deploy a django project for production sites.
Stars: ✭ 85 (+553.85%)
Mutual labels:  django-rest-framework
drf-starter-template
DRF Starter Template with drf-yasg, heroku deployment ready config, CORS config
Stars: ✭ 25 (+92.31%)
Mutual labels:  django-rest-framework
django todo app
python django를 활용한 웹 개발 튜토리얼! todo_app 만들기
Stars: ✭ 82 (+530.77%)
Mutual labels:  django-rest-framework
django-jsonapi-training
Columbia University IT developer training on using Django, REST and {json:api}
Stars: ✭ 25 (+92.31%)
Mutual labels:  django-rest-framework
Django-Ionic-Integration
Section 3 of the Django + Angular + Ionic Course
Stars: ✭ 21 (+61.54%)
Mutual labels:  django-rest-framework
django-rest-framework-condition
Decorators @​condition, @​last_modified and @​etag for Django Rest Framework
Stars: ✭ 26 (+100%)
Mutual labels:  django-rest-framework
django-experience
Tutorial Django Experience 2022
Stars: ✭ 173 (+1230.77%)
Mutual labels:  drf

Django Rest Multi Token Auth

PyPI Test status Codecov

This django app is an extension for the Django Rest Framework. It tries to overcome the limitation of Token Authentication, which only uses a single token per user.

How to use

Install:

pip install drf-multitokenauth

Add 'drf_multitokenauth' to your INSTALLED_APPS in your Django settings file:

INSTALLED_APPS = (
    ...
    'django.contrib.auth',
    ...
    'rest_framework',
    ...
    'drf_multitokenauth',
    ...
)

Configure Django REST Framework to use 'drf_multitokenauth.coreauthentication.MultiTokenAuthentication':

REST_FRAMEWORK = {
    ...
    'DEFAULT_AUTHENTICATION_CLASSES': [
        ...
        'drf_multitokenauth.coreauthentication.MultiTokenAuthentication',
        ...
    ],
    ...
}

And add the auth urls to your Django url settings:

from django.conf.urls import include
from django.urls import re_path


urlpatterns = [
    ...
    re_path(r'^api/auth/', include('drf_multitokenauth.urls', namespace='multi_token_auth')),
    ...
]    

The following endpoints are provided:

  • login - takes username, password and an optional token_name; on success an auth token is returned
  • logout

Signals

  • pre_auth(username, password) - Fired when an authentication (login) is starting
  • post_auth(user) - Fired on successful auth

Tests

See folder tests/. Basically, all endpoints are covered with multiple unit tests.

Follow below instructions to run the tests. You may exchange the installed Django and DRF versions according to your requirements. ⚠️ Depending on your local environment settings you might need to explicitly call python3 instead of python.

# install dependencies
python -m pip install --upgrade pip
pip install -r requirements.txt

# setup environment
pip install -e .
python setup.py install

# run tests
cd tests && python manage.py test

Cache Backend

If you want to use a cache for the session store, you can install django-memoize and add 'memoize' to INSTALLED_APPS.

Then you need to use CachedMultiTokenAuthentication instead of MultiTokenAuthentication.

pip install django-memoize

Django Compatibility Matrix

If your project uses an older verison of Django or Django Rest Framework, you can choose an older version of this project.

This Project Python Version Django Version Django Rest Framework
2.0.* 3.7+ 3.2, 4.0, 4.1 3.12, 3.13
1.5.* 3.7+ 3.2, 4.0, 4.1 3.12, 3.13
1.4.* 3.6+ 2.2, 3.2 3.9, 3.10, 3.11, 3.12
1.3.* 2.7, 3.4+ 1.11, 2.0 3.6, 3.7, 3.8
1.2.* 2.7, 3.4+ 1.8, 1.11, 2.0 3.6, 3.7, 3.8

Make sure to use at least DRF 3.10 when using Django 3.0 or newer.

Releases prior to 2.0.0 where published as django-rest-multitokenauth. Newer releases are published as drf-multitokenauth.

Migrating from 1.x to 2.x

  1. Uninstall django-rest-multitokenauth
  2. Install drf-multitokenauth
  3. Run the migration SQL bellow:
    ALTER TABLE django_rest_multitokenauth_multitoken RENAME to drf_multitokenauth_multitoken;
    UPDATE django_migrations SET app = 'drf_multitokenauth' WHERE app = 'django_rest_multitokenauth';
    UPDATE django_content_type SET app_label = 'drf_multitokenauth' WHERE app_label = 'django_rest_multitokenauth';
    
  4. Run Django migrations

Changelog / Releases

All releases should be listed in the releases tab on github.

See CHANGELOG.md for a more detailed listing.

License

This project is published with the BSD 3 Clause License. See https://choosealicense.com/licenses/bsd-3-clause-clear/ for more information about what this means.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].