From 7de1822447fb622522fdce31d0f0e02fa3cdcbd5 Mon Sep 17 00:00:00 2001 From: deyk Date: Mon, 16 Apr 2012 11:46:59 -0700 Subject: [PATCH] Changed from custom attribute callback to signal for collecting custom attributes. --- cas_provider/signals.py | 2 ++ cas_provider/views.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cas_provider/signals.py b/cas_provider/signals.py index 5a16f9f..648a0de 100644 --- a/cas_provider/signals.py +++ b/cas_provider/signals.py @@ -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']) diff --git a/cas_provider/views.py b/cas_provider/views.py index 3f2607f..e896fba 100644 --- a/cas_provider/views.py +++ b/cas_provider/views.py @@ -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') -- 2.20.1