Django Admin Two-Factor Authentication, allows you to login django admin with google authenticator.

Overview

Django Admin Two-Factor Authentication

Django Admin Two-Factor Authentication, allows you to login django admin with google authenticator.


Why Django Admin Two-Factor Authentication?

  • Using google authenticator to login your Django admin.
  • Used jquery confirm dialog to get code.
  • Simple interface
  • Easy integration

Django Admin Two-Factor Auth


How to use it

  • Download and install last version of Django Admin Two-Factor Authentication:
$ pip install django-admin-two-factor
# or
$ easy_install django-admin-two-factor
  • Add 'admin_two_factor' application to the INSTALLED_APPS setting of your Django project settings.py file (note it should be before 'django.contrib.admin'):
INSTALLED_APPS = (
'admin_two_factor.apps.TwoStepVerificationConfig',
'django.contrib.admin',
# ...
)
  • Migrate admin_two_factor:
$ python manage.py migrate admin_two_factor
$ # or
$ python manage.py syncdb
  • Add ‍‍‍‍ADMIN_TWO_FACTOR_NAME in your settings.py. This value will be displayed in Google Authenticator.
ADMIN_TWO_FACTOR_NAME = 'PROJECT_NAME'
  • Include the Admin Two Factor URL config in PROJECT_CORE/urls.py:
urlpatterns = [
path('admin/', admin.site.urls),
path('two_factor/', include(('admin_two_factor.urls', 'admin_two_factor'), namespace='two_factor')),
# ...
]
  • Collect static if you are in production environment:
$ python manage.py collectstatic
  • Clear your browser cache

Start the app

$ # Set up the database
$ python manage.py makemigrations
$ python manage.py migrate
$
$ # Create the superuser
$ python manage.py createsuperuser
$
$ # Start the application (development mode)
$ python manage.py runserver # default port 8000
  • Access the admin section in the browser: http://127.0.0.1:8000/

ScreenShoots


  • User List: the users who have enabled two-factor auth

Django Admin Two-Factor Auth: User List


  • Add New User:

Django Admin Two-Factor Auth: Add New User


  • Scan QRCode and enter the valid code:

Django Admin Two-Factor Auth: Scan QRCode


Django Admin Two-Factor Auth: Login with Code

You might also like...
Beihang University Network Authentication Login

北航自动网络认证使用说明 主文件 gw_buaa.py # @file gw_buaa.py # @author Dong # @date 2022-01-25 # @email [email protected] # @brief This is a python script to l

Mock authentication API that acceccpts email and password and returns authentication result.

Mock authentication API that acceccpts email and password and returns authentication result.

Django CAS 1.0/2.0/3.0 client authentication library, support Django 2.0, 2.1, 2.2, 3.0 and Python 3.5+

django-cas-ng django-cas-ng is Django CAS (Central Authentication Service) 1.0/2.0/3.0 client library to support SSO (Single Sign On) and Single Logou

Login System Using Django

Login System Django

A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

REST implementation of Django authentication system.
REST implementation of Django authentication system.

djoser REST implementation of Django authentication system. djoser library provides a set of Django Rest Framework views to handle basic actions such

Authentication Module for django rest auth

django-rest-knox Authentication Module for django rest auth Knox provides easy to use authentication for Django REST Framework The aim is to allow for

Authentication for Django Rest Framework

Dj-Rest-Auth Drop-in API endpoints for handling authentication securely in Django Rest Framework. Works especially well with SPAs (e.g React, Vue, Ang

JSON Web Token Authentication support for Django REST Framework

REST framework JWT Auth Notice This project is currently unmaintained. Check #484 for more details and suggested alternatives. JSON Web Token Authenti

Comments
  • Forbidden (CSRF token from the 'X-Csrftoken' HTTP header has incorrect length.): /two_factor/verification/

    Forbidden (CSRF token from the 'X-Csrftoken' HTTP header has incorrect length.): /two_factor/verification/

    Hi

    Thank you for your job.

    It was working perfectly on my dev environment but not on production. I think the difference is that I am using everything very secure:

    SESSION_COOKIE_SECURE="True"
    SESSION_COOKIE_HTTPONLY="True"
    CSRF_COOKIE_HTTPONLY="True"
    SECURE_BROWSER_XSS_FILTER="True"
    DJANGO_SECURE_SSL_REDIRECT="True"
    X_FRAME_OPTIONS="DENY"
    

    In the log I get Forbidden (CSRF token from the 'X-Csrftoken' HTTP header has incorrect length.): /two_factor/verification/

    When I inspect the request in the browser on the PUT request, in the request header I have : x-csrftoken: undefined

    I am not sure but may be this is a way : https://docs.djangoproject.com/fr/4.0/ref/csrf/#setting-the-token-on-the-ajax-request

    Also you may add in the documentation to allow PUT request on the webserver for this URL /two_factor/verification/.

    opened by pulse-mind 1
  • (fields.E301) Field defines a relation with the model 'auth.User'

    (fields.E301) Field defines a relation with the model 'auth.User'

    Hello, Please add support for Django custom User model. model.py replace line 8

    from django.contrib.auth.models import User

    with from django.contrib.auth import get_user_model

    line 15 User = get_user_model()

    I tested it pass ok with migrate

    Im not 100% sure if it fully works like this or need more modifications

    opened by residentcode 3
Releases(v0.0.2)
Owner
Iman Karimi
Experienced web developer with a demonstrated history of working in the web related service and applications industry.
Iman Karimi
Corsair_scan is a security tool to test Cross-Origin Resource Sharing (CORS).

Welcome to Corsair_scan Corsair_scan is a security tool to test Cross-Origin Resource Sharing (CORS) misconfigurations. CORS is a mechanism that allow

Santander Security Research 116 Nov 09, 2022
This is a Python library for accessing resources protected by OAuth 2.0.

This is a client library for accessing resources protected by OAuth 2.0. Note: oauth2client is now deprecated. No more features will be added to the l

Google APIs 787 Dec 13, 2022
Skit-auth - Authorization for skit.ai's platform

skit-auth This is a simple authentication library for Skit's platform. Provides

Skit 3 Jan 08, 2022
Multi-user accounts for Django projects

django-organizations Summary Groups and multi-user account management Author Ben Lopatin (http://benlopatin.com) Status Separate individual user ident

Ben Lopatin 1.1k Jan 02, 2023
python-social-auth and oauth2 support for django-rest-framework

Django REST Framework Social OAuth2 This module provides OAuth2 social authentication support for applications in Django REST Framework. The aim of th

1k Dec 22, 2022
Authentication with fastapi and jwt cd realistic

Authentication with fastapi and jwt cd realistic Dependencies bcrypt==3.1.7 data

Fredh Macau 1 Jan 04, 2022
A Python tool to generate and refresh Amazon access tokens.

amazon_auth A Python tool to generate and refresh Amazon access tokens. Description This tool generates and outputs Amazon access and refresh tokens f

15 Nov 21, 2022
Imia is an authentication library for Starlette and FastAPI (python 3.8+).

Imia Imia (belarussian for "a name") is an authentication library for Starlette and FastAPI (python 3.8+). Production status The library is considered

Alex Oleshkevich 91 Nov 24, 2022
Easy and secure implementation of Azure AD for your FastAPI APIs 🔒 Single- and multi-tenant support.

Easy and secure implementation of Azure AD for your FastAPI APIs 🔒 Single- and multi-tenant support.

Intility 220 Jan 05, 2023
🔐 Login & Register System

🔐 Login & Register System This is a developable login and register system. Enter your username and password to register or login to account. Automati

Firdevs Akbayır 10 Dec 12, 2022
Login-python - Login system made in Python, using native libraries

login-python Sistema de login feito 100% em Python, utilizando bibliotecas nativ

Nicholas Gabriel De Matos Leal 2 Jan 28, 2022
Simple extension that provides Basic, Digest and Token HTTP authentication for Flask routes

Flask-HTTPAuth Simple extension that provides Basic and Digest HTTP authentication for Flask routes. Installation The easiest way to install this is t

Miguel Grinberg 1.1k Jan 05, 2023
API with high performance to create a simple blog and Auth using OAuth2 ⛏

DogeAPI API with high performance built with FastAPI & SQLAlchemy, help to improve connection with your Backend Side to create a simple blog and Cruds

Yasser Tahiri 111 Jan 05, 2023
Boilerplate/Starter Project for building RESTful APIs using Flask, SQLite, JWT authentication.

auth-phyton Boilerplate/Starter Project for building RESTful APIs using Flask, SQLite, JWT authentication. Setup Step #1 - Install dependencies $ pip

sandhika 0 Aug 03, 2022
A module making it easier to manage Discord oAuth with Quart

quart_discord A module making it easier to manage Discord oAuth with Quart Install pip install git+https://github.com/xelA/ 5 Oct 27, 2022

Django Auth Protection This package logout users from the system by changing the password in Simple JWT REST API.

Django Auth Protection Django Auth Protection This package logout users from the system by changing the password in REST API. Why Django Auth Protecti

Iman Karimi 5 Oct 26, 2022
Simple implementation of authentication in projects using FastAPI

Fast Auth Facilita implementação de um sistema de autenticação básico e uso de uma sessão de banco de dados em projetos com tFastAPi. Instalação e con

3 Jan 08, 2022
A recipe sharing API built using Django rest framework.

Recipe Sharing API This is the backend API for the recipe sharing platform at https://mesob-recipe.netlify.app/ This API allows users to share recipes

Hannah 21 Dec 30, 2022
Implementation of Supervised Contrastive Learning with AMP, EMA, SWA, and many other tricks

SupCon-Framework The repo is an implementation of Supervised Contrastive Learning. It's based on another implementation, but with several differencies

Ivan Panshin 132 Dec 14, 2022
A Python library to create and validate authentication tokens

handshake A Python library to create and validate authentication tokens. handshake is used to generate and validate arbitrary authentication tokens th

0 Apr 26, 2022