Skip to content

Commit 37e48dc

Browse files
author
Roland Hedberg
committed
Added a possibly useful method.
1 parent 9bf14de commit 37e48dc

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/saml2/server.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from saml2.assertion import restriction_from_attribute_spec
4343
from saml2.assertion import filter_attribute_value_assertions
4444

45-
from saml2.ident import IdentDB
45+
from saml2.ident import IdentDB, decode
4646
from saml2.profile import ecp
4747

4848
logger = logging.getLogger(__name__)
@@ -700,3 +700,27 @@ def create_ecp_authn_request_response(self, acs_url, identity,
700700

701701
def close(self):
702702
self.ident.close()
703+
704+
def clean_out_user(self, name_id):
705+
"""
706+
Remove all authentication statements that belongs to a user identified
707+
by a NameID instance
708+
709+
:param name_id: NameID instance
710+
:return: The local identifier for the user
711+
"""
712+
713+
lid = self.ident.find_local_id(name_id)
714+
logger.info("Clean out %s" % lid)
715+
716+
# remove the authentications
717+
try:
718+
for _nid in [decode(x) for x in self.ident.db[lid].split(" ")]:
719+
try:
720+
self.session_db.remove_authn_statements(_nid)
721+
except KeyError:
722+
pass
723+
except KeyError:
724+
pass
725+
726+
return lid

0 commit comments

Comments
 (0)