Secure the admin site with django-otp as well

This commit is contained in:
Danielle McLean 2017-10-25 01:30:52 +11:00
parent 3f3bb05a25
commit 187412d966
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

@ -15,10 +15,16 @@ Including another URLconf
""" """
from django.conf.urls import include, url from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
from django_otp.admin import OTPAdminSite
import django.contrib.sitemaps.views as sitemap import django.contrib.sitemaps.views as sitemap
from home.sitemaps import HomeSitemap from home.sitemaps import HomeSitemap
otp_admin_site = OTPAdminSite()
for model_cls, model_admin in admin.site._registry.items():
otp_admin_site.register(model_cls, model_admin.__class__)
sections = { sections = {
'home': HomeSitemap, 'home': HomeSitemap,
} }
@ -27,7 +33,7 @@ maps = {'sitemaps': sections}
urlpatterns = [ urlpatterns = [
url('', include('home.urls')), url('', include('home.urls')),
url('^.well-known/', include('wellknowns.urls')), url('^.well-known/', include('wellknowns.urls')),
url('^admin/', admin.site.urls), url('^admin/', otp_admin_site.urls),
url('^auth/', include('lemonauth.urls')), url('^auth/', include('lemonauth.urls')),
url(r'^sitemap\.xml$', sitemap.index, maps), url(r'^sitemap\.xml$', sitemap.index, maps),