views.redirect don't handle FIRST_URL_BLACKLIST

This commit is contained in:
Thomas NOËL 2013-10-31 14:39:38 +01:00
parent 58ac7d9bb3
commit f6dbea879f
2 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import subprocess
import urlparse
import syslog
import re
from django.conf import settings
@ -8,6 +9,7 @@ from django.shortcuts import render_to_response
from django.template import RequestContext
from django.shortcuts import redirect
from django.contrib import messages
from django.http import HttpResponse
import django.contrib.auth
from authentic2.authsaml2.utils import register_next_target
@ -22,6 +24,11 @@ from django.core.mail import send_mail
def redirect302(request):
next_url = 'http://' + request.META['HTTP_HOST'] + request.META['REQUEST_URI']
# don't redirect to login page if URL is not really a web page,
# so don't create a sessiona and just stop here
for bl in settings.FIRST_URL_BLACKLIST:
if re.match(bl, next_url):
return HttpResponse("eduspot", content_type="text/plain", status=503)
return redirect('https://%s/login?next_url=%s' % (settings.HTTPS_HOSTNAME, next_url))
def index(request):

View File

@ -248,6 +248,13 @@ try:
except:
REDIRECT_URL = None
# don't handle these URLs
try:
firsturlbl = root.find('installedpackages/univnautes/config/firsturlbl').text.decode('base64').decode('iso-8859-1').splitlines()
FIRST_URL_BLACKLIST = [ u for u in firsturlbl if not re.match('^\s*($|#)', u) ]
except:
FIRST_URL_BLACKLIST = []
# /mail form
try:
EMAIL_RCPT = root.find('installedpackages/univnautestexts/config/email_rcpt').text