Add web server HTTP username and password to setup wizard

This commit is contained in:
JonnyWong16 2019-11-20 18:50:17 -08:00
parent f9a597bed9
commit 3b24bbee5f
5 changed files with 110 additions and 43 deletions

View file

@ -29,7 +29,6 @@ try:
except ImportError:
no_browser = True
import cherrypy
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger
from UniversalAnalytics import Tracker
@ -51,6 +50,7 @@ import plextv
import users
import versioncheck
import web_socket
import webstart
import plexpy.config
PROG_DIR = None
@ -1972,8 +1972,7 @@ def upgrade():
def shutdown(restart=False, update=False, checkout=False):
logger.info(u"Stopping Tautulli web server...")
cherrypy.engine.exit()
webstart.stop()
# Shutdown the websocket connection
if WEBSOCKET:

View file

@ -53,6 +53,7 @@ import pmsconnect
import users
import versioncheck
import web_socket
import webstart
from plexpy.api2 import API2
from plexpy.helpers import checked, addtoapi, get_ip, create_https_certificates, build_datatables_json, sanitize_out
from plexpy.session import get_session_info, get_session_user_id, allow_session_user, allow_session_library
@ -2829,6 +2830,18 @@ class WebInterface(object):
def configUpdate(self, **kwargs):
# Handle the variable config options. Note - keys with False values aren't getting passed
# Check if we should refresh our data
first_run = False
server_changed = False
reschedule = False
https_changed = False
refresh_libraries = False
refresh_users = False
# First run from the setup wizard
if kwargs.pop('first_run', None):
first_run = True
checked_configs = [
"launch_browser", "enable_https", "https_create_cert", "api_enabled", "freeze_db", "check_github",
"grouping_global_history", "grouping_user_history", "grouping_charts", "group_history_tables",
@ -2863,13 +2876,13 @@ class WebInterface(object):
kwargs['http_hashed_password'] = 1
# Flag to refresh JWT uuid to log out clients
kwargs['jwt_update_secret'] = True
kwargs['jwt_update_secret'] = True and not first_run
elif not kwargs.get('http_hash_password'):
kwargs['http_hashed_password'] = 0
# Flag to refresh JWT uuid to log out clients
kwargs['jwt_update_secret'] = True
kwargs['jwt_update_secret'] = True and not first_run
else:
kwargs['http_hashed_password'] = 0
@ -2879,18 +2892,6 @@ class WebInterface(object):
kwargs[plain_config] = kwargs[use_config]
del kwargs[use_config]
# Check if we should refresh our data
first_run = False
server_changed = False
reschedule = False
https_changed = False
refresh_libraries = False
refresh_users = False
# First run from the setup wizard
if kwargs.pop('first_run', None):
first_run = True
# If we change any monitoring settings, make sure we reschedule tasks.
if kwargs.get('check_github') != plexpy.CONFIG.CHECK_GITHUB or \
kwargs.get('refresh_libraries_interval') != str(plexpy.CONFIG.REFRESH_LIBRARIES_INTERVAL) or \
@ -2965,8 +2966,9 @@ class WebInterface(object):
# If first run, start websocket
if first_run:
webstart.restart()
activity_pinger.connect_server(log=True, startup=True)
# Reconfigure scheduler if intervals changed
if reschedule:
plexpy.initialize_scheduler()

View file

@ -25,6 +25,36 @@ from plexpy.helpers import create_https_certificates
from plexpy.webserve import WebInterface
def start():
logger.info(u"Tautulli WebStart :: Initializing Tautulli web server...")
web_config = {
'http_port': plexpy.HTTP_PORT,
'http_host': plexpy.CONFIG.HTTP_HOST,
'http_root': plexpy.CONFIG.HTTP_ROOT,
'http_environment': plexpy.CONFIG.HTTP_ENVIRONMENT,
'http_proxy': plexpy.CONFIG.HTTP_PROXY,
'enable_https': plexpy.CONFIG.ENABLE_HTTPS,
'https_cert': plexpy.CONFIG.HTTPS_CERT,
'https_cert_chain': plexpy.CONFIG.HTTPS_CERT_CHAIN,
'https_key': plexpy.CONFIG.HTTPS_KEY,
'http_username': plexpy.CONFIG.HTTP_USERNAME,
'http_password': plexpy.CONFIG.HTTP_PASSWORD,
'http_basic_auth': plexpy.CONFIG.HTTP_BASIC_AUTH
}
initialize(web_config)
def stop():
logger.info(u"Tautulli WebStart :: Stopping Tautulli web server...")
cherrypy.engine.exit()
def restart():
logger.info(u"Tautulli WebStart :: Restarting Tautulli web server...")
stop()
start()
def initialize(options):
# HTTPS stuff stolen from sickbeard