Changed from custom attribute callback to signal for collecting custom attributes.
authordeyk <deyk@crossway.org>
Mon, 16 Apr 2012 18:46:59 +0000 (11:46 -0700)
committerdeyk <deyk@crossway.org>
Mon, 16 Apr 2012 18:46:59 +0000 (11:46 -0700)
cas_provider/signals.py
cas_provider/views.py

index 5a16f9f..648a0de 100644 (file)
@@ -7,3 +7,5 @@ from django import dispatch
 on_cas_collect_histories = dispatch.Signal(providing_args=["for_email"])
 
 on_cas_login = dispatch.Signal(providing_args=["request"])
+
+cas_collect_custom_attributes = dispatch.Signal(providing_args=['user'])
index 3f2607f..e896fba 100644 (file)
@@ -336,12 +336,14 @@ def auth_success_response(user, pgt, proxies):
     username = etree.SubElement(auth_success, CAS + 'user')
     username.text = user.username
 
-    if settings.CAS_CUSTOM_ATTRIBUTES_CALLBACK:
-        callback = get_callable(settings.CAS_CUSTOM_ATTRIBUTES_CALLBACK)
-        attrs = callback(user)
-        if len(attrs) > 0:
-            formatter = get_callable(settings.CAS_CUSTOM_ATTRIBUTES_FORMATER)
-            formatter(auth_success, attrs)
+    attrs = {}
+    for receiver, response in signals.cas_collect_custom_attributes.send(user):
+        if response:
+            attrs.update(response)
+
+    if attrs:
+        formatter = get_callable(settings.CAS_CUSTOM_ATTRIBUTES_FORMATER)
+        formatter(auth_success, attrs)
 
     if pgt:
         pgtElement = etree.SubElement(auth_success, CAS + 'proxyGrantingTicket')