Pulled out all name_id related stuff into an own class
This commit is contained in:
@@ -136,9 +136,6 @@ def filter_attribute_value_assertions(ava, attribute_restrictions=None):
|
||||
del ava[attr]
|
||||
return ava
|
||||
|
||||
def temporary_identifier():
|
||||
return args2dict(sid(), format=saml.NAMEID_FORMAT_TRANSIENT)
|
||||
|
||||
class Policy(object):
|
||||
""" handles restrictions on assertions """
|
||||
|
||||
@@ -184,6 +181,17 @@ class Policy(object):
|
||||
|
||||
return self._restrictions
|
||||
|
||||
def get_nameid_format(self, sp_entity_id):
|
||||
try:
|
||||
form = self._restrictions[sp_entity_id]["nameid_format"]
|
||||
except KeyError:
|
||||
try:
|
||||
form = self._restrictions["default"]["nameid_format"]
|
||||
except KeyError:
|
||||
form = saml.NAMEID_FORMAT_TRANSIENT
|
||||
|
||||
return form
|
||||
|
||||
def get_name_form(self, sp_entity_id):
|
||||
form = ""
|
||||
|
||||
@@ -299,15 +307,8 @@ class Assertion(dict):
|
||||
def construct(self, sp_entity_id, in_response_to, name_id, attrconvs,
|
||||
policy):
|
||||
|
||||
print ">",attrconvs
|
||||
print ">",policy.__dict__
|
||||
print ">",policy.get_name_form(sp_entity_id)
|
||||
attr_statement = from_local(attrconvs, self,
|
||||
policy.get_name_form(sp_entity_id))
|
||||
print ">>",attr_statement
|
||||
# temporary identifier or ??
|
||||
if not name_id:
|
||||
name_id = temporary_identifier()
|
||||
|
||||
# start using now and for a hour
|
||||
conds = policy.conditions(sp_entity_id)
|
||||
|
||||
Reference in New Issue
Block a user