summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2012-04-04 18:44:55 +0200
committerLeif Johansson <leifj@sunet.se>2012-04-04 18:44:55 +0200
commit09d9ea40895bd2caa158e89723914c85517c013d (patch)
tree16ac6c1954e198ab629704654b7344b0f1483df6
parent26b131c4b09324bb36bfa511b31863b8c428e7d4 (diff)
debug
-rw-r--r--coip/apps/saml2/views.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/coip/apps/saml2/views.py b/coip/apps/saml2/views.py
index a04e4d2..d394fd6 100644
--- a/coip/apps/saml2/views.py
+++ b/coip/apps/saml2/views.py
@@ -14,6 +14,7 @@ from saml2.metadata import entity_descriptor
from saml2.saml import NAME_FORMAT_URI
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt
+from saml2.request import AttributeQuery
def get_full_path(request,path=None):
if path == None:
@@ -75,6 +76,29 @@ def metadata(request):
ed = entity_descriptor(cnf, 0)
return HttpResponse(content=ed,content_type="text/xml")
+def parse_attribute_query(aa, xml_string, decode=True):
+ """ Parse an attribute query
+
+ :param xml_string: The Attribute Query as an XML string
+ :param decode: Whether the xmlstring is base64encoded and zipped
+ :return: 3-Tuple containing:
+ subject - identifier of the subject
+ attribute - which attributes that the requestor wants back
+ query - the whole query
+ """
+ receiver_addresses = aa.conf.endpoint("attribute_service")
+ attribute_query = AttributeQuery( aa.sec, receiver_addresses)
+
+ attribute_query = attribute_query.loads(xml_string, decode=decode)
+ attribute_query = attribute_query.verify()
+ logging.info(repr(attribute_query))
+ #logging.info("KEYS: %s" % attribute_query.message.keys())
+ # Subject is described in the a saml.Subject instance
+ subject = attribute_query.subject_id()
+ attribute = attribute_query.attribute()
+
+ return subject, attribute, attribute_query.message
+
@csrf_exempt
def aq(request):
if request.method == 'POST':
@@ -83,7 +107,7 @@ def aq(request):
aa = server.Server(config=cnf, log=logging, debug=1, stype="aa")
request_xml = soap.parse_soap_enveloped_saml_attribute_query(request.raw_post_data)
logging.debug(request_xml)
- (subject, attribute, aq) = aa.parse_attribute_query(request_xml,False)
+ (subject, attribute, aq) = parse_attribute_query(aa,request_xml,False)
sp_entityid = aq.issuer.text
claims = {}