summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Thulin <fredrik@thulin.net>2019-05-14 12:15:53 +0200
committerFredrik Thulin <fredrik@thulin.net>2019-05-14 12:19:58 +0200
commit107fad11d9eee0f4d6cd8977d0ca6be8225ee857 (patch)
treea5a3c9fb59bbff9d6fd6d3a39057985a2424232b
parent20de0557af129b3ef9e9f5f82d6a67e822eb2e5f (diff)
downloadpysaml2-107fad11d9eee0f4d6cd8977d0ca6be8225ee857.tar.gz
add created_at timestamps to all mongodb documents
-rw-r--r--src/saml2/mongo_store.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/saml2/mongo_store.py b/src/saml2/mongo_store.py
index 6a8f9f45..e064f917 100644
--- a/src/saml2/mongo_store.py
+++ b/src/saml2/mongo_store.py
@@ -1,3 +1,4 @@
+import datetime
from hashlib import sha1
import logging
@@ -192,6 +193,9 @@ class MDB(object):
else:
doc = {}
doc.update(kwargs)
+ # Add timestamp to all documents to allow external garbage collecting
+ if "created_at" not in doc:
+ doc["created_at"] = datetime.datetime.utcnow()
_ = self.db.insert(doc)
def get(self, value=None, **kwargs):