diff --git a/serve.py b/serve.py index 735c0ba..17c1647 100755 --- a/serve.py +++ b/serve.py @@ -3,6 +3,8 @@ # python standard library import os import json +import base64 +import uuid # installed libraries import markdown @@ -46,7 +48,7 @@ class WebApplication(tornado.web.Application): 'static_path': os.path.join(os.path.dirname(__file__), 'static'), 'static_url_prefix': '/static/', # this is the default 'xsrf_cookies': False, # FIXME see how to do it... - 'cookie_secret': '__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__', # FIXME + 'cookie_secret': base64.b64encode(uuid.uuid4().bytes), # FIXME improve! 'login_url': '/login', 'debug': True, } @@ -88,7 +90,7 @@ class LoginHandler(BaseHandler): if self.learn.login_ok(uid, pw): print('login ok') - self.set_secure_cookie("user", str(uid)) + self.set_secure_cookie("user", str(uid), expires_days=30) self.redirect(self.get_argument("next", "/")) else: print('login failed') diff --git a/templates/learn.html b/templates/learn.html index 4ae594b..c2665e6 100644 --- a/templates/learn.html +++ b/templates/learn.html @@ -66,6 +66,11 @@