FreedomBox/plinth/urls.py
Sunil Mohan Adapa 895d8cffbc
sso: Adjust URL to CAPTCHA page needed by Django security fix
Fixes: #2170.

Starting with Django 2.2.25, re_path behavior has changed. When the regular
expression ends with a '$', a full match is performed with the regular
expression. This breaks the behavior of how we are currently matching the locked
URLs for CAPTCHA based login forms.

Tests:

- All tests are done on Debian stable with Django 2.2.25 and on Debian unstable
with Django 3.2.10.

- Go to home page, click on login link. Enter wrong password three times.
CAPTCHA page is show with URL ending with /locked. Type the correct password and
login will be successful.

- Install tt-rss. Logout. Go to /tt-rss/, redirection will happen to login page.
Enter wrong password three times. CAPTCHA page is show with URL ending with
/locked. Type the correct password and login will be successful.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-01-16 10:15:32 -05:00

33 lines
1.2 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Django URLconf file containing all urls
"""
from captcha import views as cviews
from django.urls import re_path
from stronghold.decorators import public
from . import views
urlpatterns = [
re_path(r'^$', views.index, name='index'),
re_path(r'^language-selection/$',
public(views.LanguageSelectionView.as_view()),
name='language-selection'),
re_path(r'^apps/$', views.AppsIndexView.as_view(), name='apps'),
re_path(r'^sys/$', views.system_index, name='system'),
# captcha urls are public
re_path(r'^captcha/image/(?P<key>\w+)/$', public(cviews.captcha_image),
name='captcha-image', kwargs={'scale': 1}),
re_path(r'^captcha/image/(?P<key>\w+)@2/$', public(cviews.captcha_image),
name='captcha-image-2x', kwargs={'scale': 2}),
re_path(r'^captcha/audio/(?P<key>\w+)/$', public(cviews.captcha_audio),
name='captcha-audio'),
re_path(r'^captcha/refresh/$', public(cviews.captcha_refresh),
name='captcha-refresh'),
# Notifications
re_path(r'^notification/(?P<id>[A-Za-z0-9-=]+)/dismiss/$',
views.notification_dismiss, name='notification_dismiss')
]