mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Flag update JWT UUID after restarting
This commit is contained in:
parent
f21d505ab8
commit
7498617b74
4 changed files with 15 additions and 15 deletions
|
@ -222,6 +222,12 @@ def initialize(config_file):
|
|||
CONFIG.JWT_SECRET = generate_uuid()
|
||||
CONFIG.write()
|
||||
|
||||
if CONFIG.JWT_UUID == '' or CONFIG.JWT_UPDATE_UUID:
|
||||
logger.debug(u"Generating JWT UUID...")
|
||||
CONFIG.JWT_UUID = generate_uuid()
|
||||
CONFIG.JWT_UPDATE_UUID = False
|
||||
CONFIG.write()
|
||||
|
||||
# Get the previous version from the file
|
||||
version_lock_file = os.path.join(DATA_DIR, "version.lock")
|
||||
prev_version = None
|
||||
|
|
|
@ -625,6 +625,7 @@ _CONFIG_DEFINITIONS = {
|
|||
'XBMC_ON_NEWDEVICE': (int, 'XBMC', 0),
|
||||
'JWT_SECRET': (str, 'Advanced', ''),
|
||||
'JWT_UUID': (str, 'Advanced', ''),
|
||||
'JWT_UPDATE_UUID': (bool_int, 'Advanced', 0),
|
||||
'SYSTEM_ANALYTICS': (int, 'Advanced', 1),
|
||||
'WIN_SYS_TRAY': (int, 'General', 1)
|
||||
}
|
||||
|
|
|
@ -138,15 +138,8 @@ def check_credentials(username=None, password=None, token=None, admin_login='0',
|
|||
return False, None, None
|
||||
|
||||
|
||||
def jwt_uuid(refresh=False):
|
||||
if not plexpy.CONFIG.JWT_UUID or refresh:
|
||||
plexpy.CONFIG.JWT_UUID = plexpy.generate_uuid()
|
||||
plexpy.CONFIG.write()
|
||||
return plexpy.CONFIG.JWT_UUID
|
||||
|
||||
|
||||
def check_jwt_token():
|
||||
jwt_cookie = JWT_COOKIE_NAME + jwt_uuid()
|
||||
jwt_cookie = JWT_COOKIE_NAME + plexpy.CONFIG.JWT_UUID
|
||||
jwt_token = cherrypy.request.cookie.get(jwt_cookie)
|
||||
|
||||
if jwt_token:
|
||||
|
@ -292,7 +285,7 @@ class AuthController(object):
|
|||
if payload:
|
||||
self.on_logout(payload['user'], payload['user_group'])
|
||||
|
||||
jwt_cookie = JWT_COOKIE_NAME + jwt_uuid()
|
||||
jwt_cookie = JWT_COOKIE_NAME + plexpy.CONFIG.JWT_UUID
|
||||
cherrypy.response.cookie[jwt_cookie] = 'expire'
|
||||
cherrypy.response.cookie[jwt_cookie]['expires'] = 0
|
||||
cherrypy.response.cookie[jwt_cookie]['path'] = '/'
|
||||
|
@ -338,14 +331,14 @@ class AuthController(object):
|
|||
success=True,
|
||||
oauth=bool(token))
|
||||
|
||||
jwt_cookie = JWT_COOKIE_NAME + jwt_uuid()
|
||||
jwt_cookie = JWT_COOKIE_NAME + plexpy.CONFIG.JWT_UUID
|
||||
cherrypy.response.cookie[jwt_cookie] = jwt_token
|
||||
cherrypy.response.cookie[jwt_cookie]['expires'] = int(time_delta.total_seconds())
|
||||
cherrypy.response.cookie[jwt_cookie]['path'] = '/'
|
||||
|
||||
cherrypy.request.login = payload
|
||||
cherrypy.response.status = 200
|
||||
return {'status': 'success', 'token': jwt_token.decode('utf-8'), 'uuid': jwt_uuid()}
|
||||
return {'status': 'success', 'token': jwt_token.decode('utf-8'), 'uuid': plexpy.CONFIG.JWT_UUID}
|
||||
|
||||
elif admin_login == '1' and username:
|
||||
self.on_login(username=username)
|
||||
|
|
|
@ -2856,15 +2856,15 @@ class WebInterface(object):
|
|||
else:
|
||||
kwargs['http_password'] = plexpy.CONFIG.HTTP_PASSWORD
|
||||
|
||||
# Refresh JWT uuid to log out clients
|
||||
webauth.jwt_uuid(refresh=True)
|
||||
# Flag to refresh JWT uuid to log out clients
|
||||
kwargs['jwt_update_uuid'] = True
|
||||
|
||||
elif kwargs['http_password'] and kwargs.get('http_hash_password'):
|
||||
kwargs['http_password'] = make_hash(kwargs['http_password'])
|
||||
kwargs['http_hashed_password'] = 1
|
||||
|
||||
# Refresh JWT uuid to log out clients
|
||||
webauth.jwt_uuid(refresh=True)
|
||||
# Flag to refresh JWT uuid to log out clients
|
||||
kwargs['jwt_update_uuid'] = True
|
||||
|
||||
elif not kwargs.get('http_hash_password'):
|
||||
kwargs['http_hashed_password'] = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue