Skip to content

Commit 466d75e

Browse files
author
Roland Hedberg
committed
Merge pull request #59 from fredrikt/master
add: Allow caller to supply unique reference.
2 parents e4020b7 + 41fd460 commit 466d75e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/saml2/authn_context/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def maximum(self, a, b):
4848
def better(self, a, b):
4949
return b > a
5050

51-
def add(self, spec, method, level=0, authn_authority=""):
51+
def add(self, spec, method, level=0, authn_authority="", reference=None):
5252
"""
5353
Adds a new authentication method.
5454
Assumes not more than one authentication method per AuthnContext
@@ -58,6 +58,7 @@ def add(self, spec, method, level=0, authn_authority=""):
5858
of an AuthnContext
5959
:param method: A identifier of the authentication method.
6060
:param level: security level, positive integers, 0 is lowest
61+
:param reference: Desired unique reference to this `spec'
6162
:return:
6263
"""
6364

@@ -81,7 +82,11 @@ def add(self, spec, method, level=0, authn_authority=""):
8182
raise NotImplementedError()
8283

8384
self.next += 1
84-
_ref = str(self.next)
85+
_ref = reference
86+
if _ref is None:
87+
_ref = str(self.next)
88+
89+
assert _ref not in self.db["info"]
8590
self.db["info"][_ref] = _info
8691
try:
8792
self.db["key"][key].append(_ref)

0 commit comments

Comments
 (0)