--- /dev/null
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+from django.conf import settings
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('cas_provider', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='proxygrantingticket',
+ name='serviceTicket',
+ ),
+ migrations.AddField(
+ model_name='proxygrantingticket',
+ name='pgt',
+ field=models.ForeignKey(to='cas_provider.ProxyGrantingTicket', null=True),
+ preserve_default=True,
+ ),
+ migrations.AddField(
+ model_name='proxygrantingticket',
+ name='service',
+ field=models.URLField(null=True, verbose_name='service'),
+ preserve_default=True,
+ ),
+ migrations.AddField(
+ model_name='proxygrantingticket',
+ name='user',
+ field=models.ForeignKey(default=0, verbose_name='user', to=settings.AUTH_USER_MODEL),
+ preserve_default=False,
+ ),
+ ]
class ProxyGrantingTicket(BaseTicket):
- serviceTicket = models.ForeignKey(ServiceTicket, null=True)
+ user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('user'))
+ service = models.URLField(_('service'), null=True)
+ pgt = models.ForeignKey('self', null=True)
pgtiou = models.CharField(max_length=256, verbose_name=_('PGTiou'))
prefix = 'PGT'
return _cas2_error_response(INVALID_TICKET)
pt = ProxyTicket.objects.create(proxyGrantingTicket=proxyGrantingTicket,
- user=proxyGrantingTicket.serviceTicket.user,
+ user=proxyGrantingTicket.user,
service=targetService)
return _cas2_proxy_success(pt.ticket)
if hasattr(ticket, 'proxyticket'):
pgt = ticket.proxyticket.proxyGrantingTicket
# I am issued by this proxy granting ticket
- if hasattr(pgt.serviceTicket, 'proxyticket'):
- while pgt:
- if hasattr(pgt.serviceTicket, 'proxyticket'):
- proxies += (pgt.serviceTicket.service,)
- pgt = pgt.serviceTicket.proxyticket.proxyGrantingTicket
- else:
- pgt = None
+ while pgt.pgt is not None:
+ proxies += (pgt.service,)
+ pgt = pgt.pgt
user = ticket.user
ticket.delete()
uri = list(urlsplit(pgt_url))
pgt = ProxyGrantingTicket()
- pgt.serviceTicket = ticket
- pgt.targetService = pgt_url
-
- if hasattr(ticket, 'proxyGrantingTicket'):
- # here we got a proxy ticket! tata!
- pgt.pgt = ticket.proxyGrantingTicket
+ pgt.user = ticket.user
+ pgt.service = ticket.service
+ # Remember if it's a chained PGT.
+ pgt.pgt = getattr(ticket, 'proxyGrantingTicket', None)
params = {'pgtId': pgt.ticket, 'pgtIou': pgt.pgtiou}