From: deyk Date: Wed, 18 Apr 2012 18:14:52 +0000 (-0700) Subject: Fixed handling of iterables inside attribute_formatters. X-Git-Tag: 22.4~19 X-Git-Url: https://git.mdrn.pl/django-cas-provider.git/commitdiff_plain/3b6a516384b03ed3b2bc71f09209d4274d3e6748?ds=sidebyside Fixed handling of iterables inside attribute_formatters. --- diff --git a/cas_provider/attribute_formatters.py b/cas_provider/attribute_formatters.py index d61af0f..55eb4dd 100644 --- a/cas_provider/attribute_formatters.py +++ b/cas_provider/attribute_formatters.py @@ -11,7 +11,7 @@ def jasig(auth_success, attrs): style = etree.SubElement(attributes, CAS + 'attraStyle') style.text = u'Jasig' for name, value in attrs.items(): - if isinstance(value, collections.Iterable): + if isinstance(value, collections.Iterable) and not isinstance(value, basestring): for e in value: element = etree.SubElement(attributes, CAS + name) element.text = e @@ -24,7 +24,7 @@ def ruby_cas(auth_success, attrs): style = etree.SubElement(auth_success, CAS + 'attraStyle') style.text = u'RubyCAS' for name, value in attrs.items(): - if isinstance(value, list): + if isinstance(value, collections.Iterable) and not isinstance(value, basestring): for e in value: element = etree.SubElement(auth_success, CAS + name) element.text = e @@ -36,7 +36,7 @@ def ruby_cas(auth_success, attrs): def name_value(auth_success, attrs): etree.SubElement(auth_success, CAS + 'attribute', name=u'attraStyle', value=u'Name-Value') for name, value in attrs.items(): - if isinstance(value, list): + if isinstance(value, collections.Iterable) and not isinstance(value, basestring): for e in value: etree.SubElement(auth_success, CAS + 'attribute', name=name, value=e) else: diff --git a/cas_provider/views.py b/cas_provider/views.py index 3572303..6632722 100644 --- a/cas_provider/views.py +++ b/cas_provider/views.py @@ -343,6 +343,7 @@ def auth_success_response(user, pgt, proxies): identifiers = [i for sr, rr in signals.on_cas_collect_histories.send(sender=validate, for_user=user) for i in rr] + if identifiers: attrs['identifiers'] = identifiers