summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2014-12-28 16:59:16 +0100
committerRoland Hedberg <roland.hedberg@adm.umu.se>2014-12-28 16:59:16 +0100
commit37e48dcbdc9eda77e9efddf41fad40152e76bc26 (patch)
treebc7943733bdc19805742f50acd7b0bb509935bc7
parent9bf14de5447ad8f08b30858aac864a689ad0d4a6 (diff)
downloadpysaml2-37e48dcbdc9eda77e9efddf41fad40152e76bc26.tar.gz
Added a possibly useful method.
-rw-r--r--src/saml2/server.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/saml2/server.py b/src/saml2/server.py
index 8eee26af..9ae6bff2 100644
--- a/src/saml2/server.py
+++ b/src/saml2/server.py
@@ -42,7 +42,7 @@ from saml2.assertion import Policy
from saml2.assertion import restriction_from_attribute_spec
from saml2.assertion import filter_attribute_value_assertions
-from saml2.ident import IdentDB
+from saml2.ident import IdentDB, decode
from saml2.profile import ecp
logger = logging.getLogger(__name__)
@@ -700,3 +700,27 @@ class Server(Entity):
def close(self):
self.ident.close()
+
+ def clean_out_user(self, name_id):
+ """
+ Remove all authentication statements that belongs to a user identified
+ by a NameID instance
+
+ :param name_id: NameID instance
+ :return: The local identifier for the user
+ """
+
+ lid = self.ident.find_local_id(name_id)
+ logger.info("Clean out %s" % lid)
+
+ # remove the authentications
+ try:
+ for _nid in [decode(x) for x in self.ident.db[lid].split(" ")]:
+ try:
+ self.session_db.remove_authn_statements(_nid)
+ except KeyError:
+ pass
+ except KeyError:
+ pass
+
+ return lid \ No newline at end of file