summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-09-20 17:46:13 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-09-20 17:46:13 +0200
commitd49a1c3983e7b0e0f99a093fe6bfc2dd63f1ab36 (patch)
tree43bd10b897306fbee188f65dca62f59631382bb6 /pykolab
parent7d1e0aae9bbd1599968cf1ddd7a1b7ac04a7c9fa (diff)
downloadpykolab-d49a1c3983e7b0e0f99a093fe6bfc2dd63f1ab36.tar.gz
Make sure entries are purged, and that the key is long enough
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/auth/ldap/auth_cache.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/pykolab/auth/ldap/auth_cache.py b/pykolab/auth/ldap/auth_cache.py
index 12f362c..ba14262 100644
--- a/pykolab/auth/ldap/auth_cache.py
+++ b/pykolab/auth/ldap/auth_cache.py
@@ -71,7 +71,7 @@ entry_table = Table(
'entries', metadata,
Column('id', Integer, primary_key=True),
Column('domain', String(128), index=True, nullable=True),
- Column('key', String(128), index=True, nullable=False),
+ Column('key', String(512), index=True, nullable=False),
Column('value', String(128), nullable=False),
Column('last_change', DateTime, nullable=False, default=datetime.datetime.now())
)
@@ -114,9 +114,8 @@ def set_entry(key, value):
db.commit()
-#def purge_entries():
- #db = init_db()
- #db.query(Entry).filter(Entry.last_change <= datetime.datetime.now()).delete()
+def purge_entries(db):
+ db.query(Entry).filter(Entry.last_change <= (datetime.datetime.now() - datetime.timedelta(1))).delete()
def init_db():
"""
@@ -127,12 +126,16 @@ def init_db():
if not db == None:
return db
- db_uri = 'sqlite:///%s/auth_cache.db' % (KOLAB_LIB_PATH)
+ db_uri = conf.get('ldap', 'auth_cache_uri')
+ if db_uri == None:
+ db_uri = 'sqlite:///%s/auth_cache.db' % (KOLAB_LIB_PATH)
+
echo = conf.debuglevel > 8
engine = create_engine(db_uri, echo=echo)
metadata.create_all(engine)
Session = sessionmaker(bind=engine)
db = Session()
+ purge_entries(db)
return db