Save cherrypy sessions to disk instead of ram

This commit is contained in:
JonnyWong16 2017-12-31 14:28:27 -08:00
parent 645ef86c75
commit b2b728a3cc
2 changed files with 22 additions and 20 deletions

View file

@ -71,7 +71,7 @@ def user_login(username=None, password=None):
if result: if result:
# Refresh the users list to make sure we have all the correct permissions. # Refresh the users list to make sure we have all the correct permissions.
users.refresh_users() refresh_users()
# Successful login # Successful login
return True return True
else: else:
@ -243,7 +243,6 @@ class AuthController(object):
expiry = datetime.now() + (timedelta(days=30) if remember_me == '1' else timedelta(minutes=60)) expiry = datetime.now() + (timedelta(days=30) if remember_me == '1' else timedelta(minutes=60))
cherrypy.session.regenerate()
cherrypy.request.login = username cherrypy.request.login = username
cherrypy.session[SESSION_KEY] = {'user_id': user_id, cherrypy.session[SESSION_KEY] = {'user_id': user_id,
'user': username, 'user': username,

View file

@ -69,14 +69,14 @@ def initialize(options):
if options['http_password']: if options['http_password']:
logger.info(u"Tautulli WebStart :: Web server authentication is enabled, username is '%s'", options['http_username']) logger.info(u"Tautulli WebStart :: Web server authentication is enabled, username is '%s'", options['http_username'])
if options['http_basic_auth']: if options['http_basic_auth']:
auth_enabled = session_enabled = False session_enabled = auth_enabled = False
basic_auth_enabled = True basic_auth_enabled = True
else: else:
options_dict['tools.sessions.on'] = auth_enabled = session_enabled = True options_dict['tools.sessions.on'] = session_enabled = auth_enabled = True
basic_auth_enabled = False basic_auth_enabled = False
cherrypy.tools.auth = cherrypy.Tool('before_handler', webauth.check_auth) cherrypy.tools.auth = cherrypy.Tool('before_handler', webauth.check_auth)
else: else:
auth_enabled = session_enabled = basic_auth_enabled = False session_enabled = auth_enabled = basic_auth_enabled = False
if options['http_root'].strip('/'): if options['http_root'].strip('/'):
plexpy.HTTP_ROOT = options['http_root'] = '/' + options['http_root'].strip('/') + '/' plexpy.HTTP_ROOT = options['http_root'] = '/' + options['http_root'].strip('/') + '/'
@ -93,9 +93,12 @@ def initialize(options):
'tools.gzip.mime_types': ['text/html', 'text/plain', 'text/css', 'tools.gzip.mime_types': ['text/html', 'text/plain', 'text/css',
'text/javascript', 'application/json', 'text/javascript', 'application/json',
'application/javascript'], 'application/javascript'],
'tools.auth.on': auth_enabled,
'tools.sessions.on': session_enabled, 'tools.sessions.on': session_enabled,
'tools.session.name': 'my_session_id',
'tools.sessions.storage_type': 'file',
'tools.sessions.storage_path': plexpy.CONFIG.CACHE_DIR,
'tools.sessions.timeout': 30 * 24 * 60, # 30 days 'tools.sessions.timeout': 30 * 24 * 60, # 30 days
'tools.auth.on': auth_enabled,
'tools.auth_basic.on': basic_auth_enabled, 'tools.auth_basic.on': basic_auth_enabled,
'tools.auth_basic.realm': 'Tautulli web server', 'tools.auth_basic.realm': 'Tautulli web server',
'tools.auth_basic.checkpassword': cherrypy.lib.auth_basic.checkpassword_dict({ 'tools.auth_basic.checkpassword': cherrypy.lib.auth_basic.checkpassword_dict({
@ -112,8 +115,8 @@ def initialize(options):
'tools.caching.delay': 0, 'tools.caching.delay': 0,
'tools.expires.on': True, 'tools.expires.on': True,
'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days 'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
'tools.auth.on': False, 'tools.sessions.on': False,
'tools.sessions.on': False 'tools.auth.on': False
}, },
'/images': { '/images': {
'tools.staticdir.on': True, 'tools.staticdir.on': True,
@ -123,8 +126,8 @@ def initialize(options):
'tools.caching.delay': 0, 'tools.caching.delay': 0,
'tools.expires.on': True, 'tools.expires.on': True,
'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days 'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
'tools.auth.on': False, 'tools.sessions.on': False,
'tools.sessions.on': False 'tools.auth.on': False
}, },
'/css': { '/css': {
'tools.staticdir.on': True, 'tools.staticdir.on': True,
@ -134,8 +137,8 @@ def initialize(options):
'tools.caching.delay': 0, 'tools.caching.delay': 0,
'tools.expires.on': True, 'tools.expires.on': True,
'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days 'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
'tools.auth.on': False, 'tools.sessions.on': False,
'tools.sessions.on': False 'tools.auth.on': False
}, },
'/fonts': { '/fonts': {
'tools.staticdir.on': True, 'tools.staticdir.on': True,
@ -145,8 +148,8 @@ def initialize(options):
'tools.caching.delay': 0, 'tools.caching.delay': 0,
'tools.expires.on': True, 'tools.expires.on': True,
'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days 'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
'tools.auth.on': False, 'tools.sessions.on': False,
'tools.sessions.on': False 'tools.auth.on': False
}, },
'/js': { '/js': {
'tools.staticdir.on': True, 'tools.staticdir.on': True,
@ -156,8 +159,8 @@ def initialize(options):
'tools.caching.delay': 0, 'tools.caching.delay': 0,
'tools.expires.on': True, 'tools.expires.on': True,
'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days 'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
'tools.auth.on': False, 'tools.sessions.on': False,
'tools.sessions.on': False 'tools.auth.on': False
}, },
'/cache': { '/cache': {
'tools.staticdir.on': True, 'tools.staticdir.on': True,
@ -167,8 +170,8 @@ def initialize(options):
'tools.caching.delay': 0, 'tools.caching.delay': 0,
'tools.expires.on': True, 'tools.expires.on': True,
'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days 'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
'tools.auth.on': False, 'tools.sessions.on': False,
'tools.sessions.on': False 'tools.auth.on': False
}, },
#'/pms_image_proxy': { #'/pms_image_proxy': {
# 'tools.staticdir.on': True, # 'tools.staticdir.on': True,
@ -189,8 +192,8 @@ def initialize(options):
'tools.caching.delay': 0, 'tools.caching.delay': 0,
'tools.expires.on': True, 'tools.expires.on': True,
'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days 'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
'tools.auth.on': False, 'tools.sessions.on': False,
'tools.sessions.on': False 'tools.auth.on': False
} }
} }