layerindex-web/urls.py
Paul Eggleton 23194fc5d4 Add CAPTCHA to registration/password reset forms
Extend and override the default views so we can extend and override the
default forms to add a CAPTCHA field. This should prevent the automated
account creation requests we've been seeing on layers.openembedded.org
(luckily failing anyway due to bad domain names), but in any case this
also improves security by making it harder to do user enumeration.

For the registration page in particular, because Django's forms logic
tries to be helpful by showing all errors at once, we need to change it
so that if there's an error for the CAPTCHA then you only see that error
and no other - in particular you won't see "that username already
exists" if that is the case.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-11-06 11:31:07 +13:00

40 lines
1.2 KiB
Python

# layerindex-web - URLs
#
# Based on the Django project template
#
# Copyright (c) Django Software Foundation and individual contributors.
# All rights reserved.
from django.conf.urls import include, url
from django.core.urlresolvers import reverse_lazy
from django.views.generic import RedirectView
from layerindex.auth_views import CaptchaRegistrationView, CaptchaPasswordResetView
from django.contrib import admin
admin.autodiscover()
import settings
urlpatterns = [
url(r'^layerindex/', include('layerindex.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/password/reset/$',
CaptchaPasswordResetView.as_view(
email_template_name='registration/password_reset_email.txt',
success_url=reverse_lazy('auth_password_reset_done')),
name='auth_password_reset'),
url(r'^accounts/register/$', CaptchaRegistrationView.as_view(),
name='registration_register'),
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^captcha/', include('captcha.urls')),
]
if 'rrs' in settings.INSTALLED_APPS:
urlpatterns += [
url(r'^rrs/', include('rrs.urls')),
]
urlpatterns += [
url(r'.*', RedirectView.as_view(url='/layerindex/', permanent=False)),
]