Package: django-good-otp
Yet Another Implementation of OTP for DjangoWhat This?This script is "Yet Another Implementation" of 2 factor authentication.Why I re-invent?First, I triedDjango OTP, but 2 FA code is required though it should be
optional. Moreover, Admin Panel to edit/fix secret key is not provided.Then, I trieddjango-two-factor-auth, but I found it is the wrapper ofDjango OTPthat requires 2FA code to the user who doesn't have 2FA enabled.How to useInstall this script. There'spip packageand you can install it bypip install django_good_otp.Create a Django project as usual.Edit settings.py. You will need to edit INSTALLED_APPS and
AUTHENTICATION_BACKENDS. For detail, referEdit Settingssection.Run migration as usual.Editurl.pyof your root URL config to enable QR Code.
For details, Check outURL Routingsection.To enable admin panel, you will need to write very small code.
For details, Check outEnable Admin Panelsection.To use 2FA on Admin panel login, you will also need to write very simple
code. For details, Check outEnable Admin Panelsection.Edit settingsYou will need to edit configuration such settings.py. The variable to edit
isINSTALLED_APPSandAUTHENTICATION_BACKENDS.INSTALLED_APPSYou will just need to add'django_otp.DjangoOTP'after'django.contrib.auth'i.e. it should be like this:settings.pyINSTALLED_APPS=['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles',"django_otp.DjangoOTP"]Note that this depends on the case. i.e. If you have more apps
installed/uninstalled, yourINSTALLED_APPSlist might be longer/shorter than
this.AUTHENTICATION_BACKENDSTo use 2 FA, you will need to replace authentication backend with the backend
this module provides. i.e. just setAUTHENTICATION_BACKENDSinsettings.pyto("django_otp.backends.OTPAuthBackend", ). i.e. like this:settings.pyAUTHENTICATION_BACKENDS=("django_otp.backends.OTPAuthBackend",)URL RoutingThis module supports QRCode to transfer Secret Key to your device. To
use it, you will need to adddjango_otp.urlswithincludefunction
like this:urls.pyfromdjango.conf.urlsimporturl,includefromdjango.contribimportadminurlpatterns=[url(r'^admin/',admin.site.urls),url(r'^qr/',include("django_otp.urls"))]Enable Admin PanelAdmin PanelBy default, Admin Panel of the model that stores secret key isdisabled.
To enable Admin Panel, you will need to callOTPAdmin.enable()method like
this:urls.pyfromdjango.conf.urlsimporturl,includefromdjango.contribimportadminfromdjango_otp.adminimportOTPAdminOTPAdmin.enable()urlpatterns=[url(r'^admin/',admin.site.urls),url(r'^qr/',include("django_otp.urls"))]Using 2FA form on adminsiteUnfortunately, login template of administration site doesn't handle custom
login form. Therefore, to use 2FA-ready admin form, you will need to replaceadmin.sitewithdjango_otp.admin.AdminSite. i.e. like this:urls.pyfromdjango.conf.urlsimporturl,includefromdjango.contribimportadminfromdjango_otp.adminimportAdminSiteOTPAdmin.enable()admin.site=AdminSite()urlpatterns=[url(r'^admin/',admin.site.urls),url(r'^qr/',include("django_otp.urls"))]Other stuffFor other stuff that is not documented here, please refer thesource code.ContributionThe code is onGithuband you can create issues/PRs. Making issues is
appreciated, however,making PRs is more appreciated.