Commit 5dfd40c1 by Ed Crewe

add alternative /proxyValidate to /login url if its a proxy ticket

parent 7e3dc58a
......@@ -6,7 +6,7 @@ from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from django_cas.exceptions import CasTicketException, CasConfigException
class AuthTgt(models.Model):
class Tgt(models.Model):
username = models.CharField(max_length = 255, unique = True)
tgt = models.CharField(max_length = 255)
......@@ -40,7 +40,7 @@ class AuthTgt(models.Model):
finally:
page.close()
class AuthPgtIOU(models.Model):
class PgtIOU(models.Model):
pgtIou = models.CharField(max_length = 255, unique = True)
tgt = models.CharField(max_length = 255)
timestamp = models.DateTimeField(auto_now = True)
......
......@@ -43,13 +43,15 @@ def _redirect_url(request):
return next
def _login_url(service):
def _login_url(service, ticket='ST'):
"""Generates CAS login URL"""
LOGINS = {'ST':'login',
'PT':'proxyValidate'}
params = {'service': service}
if settings.CAS_EXTRA_LOGIN_PARAMS:
params.update(settings.CAS_EXTRA_LOGIN_PARAMS)
return urljoin(settings.CAS_SERVER_URL, 'login') + '?' + urlencode(params)
login = LOGINS.get(ticket[:2],'login')
return urljoin(settings.CAS_SERVER_URL, login) + '?' + urlencode(params)
def _logout_url(request, next_page=None):
......@@ -85,12 +87,12 @@ def login(request, next_page=None, required=False):
user.message_set.create(message=message)
return HttpResponseRedirect(next_page)
elif settings.CAS_RETRY_LOGIN or required:
return HttpResponseRedirect(_login_url(service))
return HttpResponseRedirect(_login_url(service, ticket))
else:
error = "<h1>Forbidden</h1><p>Login failed.</p>"
return HttpResponseForbidden(error)
else:
return HttpResponseRedirect(_login_url(service))
return HttpResponseRedirect(_login_url(service, ticket))
def logout(request, next_page=None):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment