From 107fad11d9eee0f4d6cd8977d0ca6be8225ee857 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Tue, 14 May 2019 12:15:53 +0200 Subject: add created_at timestamps to all mongodb documents --- src/saml2/mongo_store.py | 4 ++++ 1 file changed, 4 insertions(+) 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): -- cgit v1.2.1