Commit 46c2d4be authored by Jogi Hofmüller's avatar Jogi Hofmüller

Add class SessionList

parent 5efac6a1
......@@ -12,17 +12,49 @@ def logmsg(msg):
gdbfile = '/app/data/gdb/gdb.json'
# dir for static html files; mainly needed for letsencrypt's ceertbot
# dir for static html files; mainly needed for letsencrypt's certbot
basedir = '/app/data/www'
gdb = Gdb(gdbfile)
class SessionList(list):
def __init__(self, userlist):
self.userlist = userlist
self.timeout = 60 * 60
def authenticate(self, name, password):
user = self.userlist.authenticate(name, password)
if not user:
return None
user.lastseen = time()
gdb.modified = True
return user
def validate(self, cookie):
if not cookie:
return None
u = cookie.decode('utf8')
for user in self:
if == u:
if user.lastseen + self.timeout < time():
logmsg('session timeout for user={}'.format(u))
return None
user.lastseen = time()
return user
logmsg('user={} not found'.format(u))
return None
gdb = Gdb(gdbfile, logmsg)
sessionlist = SessionList(gdb.ulist)
# a handler for static files
class FileHandler(web.RequestHandler):
class FileHandler(tornado.web.RequestHandler):
def get(self, path):
if path == '':
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment