Skip to content

Commit e766d3c

Browse files
Merge pull request #617 from SUNET/eduid-mongodb_timestamps
Add timestamps for ident mongodb documents
2 parents 4e660fe + 107fad1 commit e766d3c

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

@@ -211,6 +212,9 @@ def store(self, value, **kwargs):
211212
else:
212213
doc = {}
213214
doc.update(kwargs)
215+
# Add timestamp to all documents to allow external garbage collecting
216+
if "created_at" not in doc:
217+
doc["created_at"] = datetime.datetime.utcnow()
214218
_ = self.db.insert(doc)
215219

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

0 commit comments

Comments
 (0)