Skip to content

Commit

Permalink
delete_one do not accept just a key as delete previous did
Browse files Browse the repository at this point in the history
change delete_one to delete_many instead of iterating through results
deleting all found documents
  • Loading branch information
johanlundberg authored and c00kiemon5ter committed Jan 23, 2023
1 parent 803eb89 commit 63b2288
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/saml2/mongo_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def get_assertions_by_subject(self, name_id=None, session_index=None, requested_
def remove_authn_statements(self, name_id):
logger.debug("remove authn about: %s", name_id)
key = sha1(code_binary(name_id)).hexdigest()
for item in self.assertion.find({"name_id_key": key}):
self.assertion.delete_one(item["_id"])
self.assertion.delete_many(filter={"name_id_key": key})

def get_authn_statements(self, name_id, session_index=None, requested_context=None):
"""
Expand Down Expand Up @@ -220,13 +219,11 @@ def get(self, value=None, **kwargs):
def remove(self, key=None, **kwargs):
if key is None:
if kwargs:
for item in self.db.find(kwargs):
self.db.delete_one(item["_id"])
self.db.delete_many(filter=kwargs)
else:
doc = {self.primary_key: key}
doc.update(kwargs)
for item in self.db.find(doc):
self.db.delete_one(item["_id"])
self.db.delete_many(filter=doc)

def keys(self):
for item in self.db.find():
Expand Down

0 comments on commit 63b2288

Please sign in to comment.