From 95db3577ec1f8d113a2f6e3d7f4fcab96d4fb45c Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Fri, 27 Sep 2013 16:19:49 +0200 Subject: [PATCH] add: Allow caller to supply unique reference. Being able to specify reference is useful to ensure consistency during upgrades in a cluster of IdP:s. --- src/saml2/authn_context/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/saml2/authn_context/__init__.py b/src/saml2/authn_context/__init__.py index 4643bd3..700ee8e 100644 --- a/src/saml2/authn_context/__init__.py +++ b/src/saml2/authn_context/__init__.py @@ -48,7 +48,7 @@ class AuthnBroker(object): def better(self, a, b): return b > a - def add(self, spec, method, level=0, authn_authority=""): + def add(self, spec, method, level=0, authn_authority="", reference=None): """ Adds a new authentication method. Assumes not more than one authentication method per AuthnContext @@ -58,6 +58,7 @@ class AuthnBroker(object): of an AuthnContext :param method: A identifier of the authentication method. :param level: security level, positive integers, 0 is lowest + :param reference: Desired unique reference to this spec :return: """ @@ -81,7 +82,9 @@ class AuthnBroker(object): raise NotImplementedError() self.next += 1 - _ref = str(self.next) + _ref = reference + if _ref is None: + _ref = str(self.next) self.db["info"][_ref] = _info try: self.db["key"][key].append(_ref)