Possibility to specify a single log out callback

This commit is contained in:
Valentin Samir 2015-06-08 18:22:10 +02:00
parent a4ff5c3d64
commit 1ada840bdc
2 changed files with 41 additions and 1 deletions

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0017_remove_user_attributs'),
]
operations = [
migrations.AddField(
model_name='servicepattern',
name='single_log_out_callback',
field=models.CharField(default=b'', help_text='URL where the SLO request will be POST. empty = service url\nThis is usefull for non HTTP proxied services.', max_length=255, verbose_name='single log out callback', blank=True),
preserve_default=True,
),
migrations.AlterField(
model_name='replaceattributname',
name='name',
field=models.CharField(help_text='name of an attribut to send to the service, use * for all attributes', max_length=255, verbose_name='name'),
preserve_default=True,
),
]

View file

@ -167,6 +167,16 @@ class ServicePattern(models.Model):
help_text=_("Enable SLO for the service") help_text=_("Enable SLO for the service")
) )
single_log_out_callback = models.CharField(
max_length=255,
default="",
blank=True,
verbose_name=_(u"single log out callback"),
help_text=_(u"URL where the SLO request will be POST. empty = service url\n" \
u"This is usefull for non HTTP proxied services.")
)
def __unicode__(self): def __unicode__(self):
return u"%s: %s" % (self.pos, self.pattern) return u"%s: %s" % (self.pos, self.pattern)
@ -344,8 +354,12 @@ class Ticket(models.Model):
'ticket': self.value 'ticket': self.value
} }
try: try:
if self.service_pattern.single_log_out_callback:
url = self.service_pattern.single_log_out_callback
else:
url = self.service
return session.post( return session.post(
self.service.encode('utf-8'), url.encode('utf-8'),
data={'logoutRequest':xml.encode('utf-8')}, data={'logoutRequest':xml.encode('utf-8')},
) )
except Exception as error: except Exception as error: