Commit 1ada840b authored by Valentin Samir's avatar Valentin Samir

Possibility to specify a single log out callback

parent a4ff5c3d
# -*- 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,
),
]
......@@ -167,6 +167,16 @@ class ServicePattern(models.Model):
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):
return u"%s: %s" % (self.pos, self.pattern)
......@@ -344,8 +354,12 @@ class Ticket(models.Model):
'ticket': self.value
}
try:
if self.service_pattern.single_log_out_callback:
url = self.service_pattern.single_log_out_callback
else:
url = self.service
return session.post(
self.service.encode('utf-8'),
url.encode('utf-8'),
data={'logoutRequest':xml.encode('utf-8')},
)
except Exception as error:
......
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