Skip to content

Commit 107fad1

Browse files
committed
add created_at timestamps to all mongodb documents
1 parent 20de055 commit 107fad1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/saml2/mongo_store.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
from hashlib import sha1
23
import logging
34

@@ -192,6 +193,9 @@ def store(self, value, **kwargs):
192193
else:
193194
doc = {}
194195
doc.update(kwargs)
196+
# Add timestamp to all documents to allow external garbage collecting
197+
if "created_at" not in doc:
198+
doc["created_at"] = datetime.datetime.utcnow()
195199
_ = self.db.insert(doc)
196200

197201
def get(self, value=None, **kwargs):

0 commit comments

Comments
 (0)