mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Remove no password set boolean
This commit is contained in:
parent
64ebe8c6d0
commit
0df39b4df5
@ -65,7 +65,7 @@ def _handle_get_root(handler, path_match, data):
|
|||||||
app_url = "frontend-{}.html".format(version.VERSION)
|
app_url = "frontend-{}.html".format(version.VERSION)
|
||||||
|
|
||||||
# auto login if no password was set, else check api_password param
|
# auto login if no password was set, else check api_password param
|
||||||
auth = ('no_password_set' if handler.server.no_password_set
|
auth = ('no_password_set' if handler.server.api_password is None
|
||||||
else data.get('api_password', ''))
|
else data.get('api_password', ''))
|
||||||
|
|
||||||
with open(INDEX_PATH) as template_file:
|
with open(INDEX_PATH) as template_file:
|
||||||
|
@ -53,10 +53,6 @@ def setup(hass, config):
|
|||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
|
|
||||||
api_password = util.convert(conf.get(CONF_API_PASSWORD), str)
|
api_password = util.convert(conf.get(CONF_API_PASSWORD), str)
|
||||||
no_password_set = api_password is None
|
|
||||||
|
|
||||||
if no_password_set:
|
|
||||||
api_password = util.get_random_string()
|
|
||||||
|
|
||||||
# If no server host is given, accept all incoming requests
|
# If no server host is given, accept all incoming requests
|
||||||
server_host = conf.get(CONF_SERVER_HOST, '0.0.0.0')
|
server_host = conf.get(CONF_SERVER_HOST, '0.0.0.0')
|
||||||
@ -66,7 +62,7 @@ def setup(hass, config):
|
|||||||
try:
|
try:
|
||||||
server = HomeAssistantHTTPServer(
|
server = HomeAssistantHTTPServer(
|
||||||
(server_host, server_port), RequestHandler, hass, api_password,
|
(server_host, server_port), RequestHandler, hass, api_password,
|
||||||
development, no_password_set)
|
development)
|
||||||
except OSError:
|
except OSError:
|
||||||
# If address already in use
|
# If address already in use
|
||||||
_LOGGER.exception("Error setting up HTTP server")
|
_LOGGER.exception("Error setting up HTTP server")
|
||||||
@ -93,14 +89,13 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer):
|
|||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def __init__(self, server_address, request_handler_class,
|
def __init__(self, server_address, request_handler_class,
|
||||||
hass, api_password, development, no_password_set):
|
hass, api_password, development):
|
||||||
super().__init__(server_address, request_handler_class)
|
super().__init__(server_address, request_handler_class)
|
||||||
|
|
||||||
self.server_address = server_address
|
self.server_address = server_address
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.api_password = api_password
|
self.api_password = api_password
|
||||||
self.development = development
|
self.development = development
|
||||||
self.no_password_set = no_password_set
|
|
||||||
self.paths = []
|
self.paths = []
|
||||||
self.sessions = SessionStore()
|
self.sessions = SessionStore()
|
||||||
|
|
||||||
@ -157,7 +152,7 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
|||||||
|
|
||||||
def log_message(self, fmt, *arguments):
|
def log_message(self, fmt, *arguments):
|
||||||
""" Redirect built-in log to HA logging """
|
""" Redirect built-in log to HA logging """
|
||||||
if self.server.no_password_set:
|
if self.server.api_password is None:
|
||||||
_LOGGER.info(fmt, *arguments)
|
_LOGGER.info(fmt, *arguments)
|
||||||
else:
|
else:
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
@ -192,8 +187,7 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
|||||||
"Error parsing JSON", HTTP_UNPROCESSABLE_ENTITY)
|
"Error parsing JSON", HTTP_UNPROCESSABLE_ENTITY)
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.server.no_password_set:
|
if self.server.api_password is None:
|
||||||
_LOGGER.warning('NO PASSWORD SET')
|
|
||||||
self.authenticated = True
|
self.authenticated = True
|
||||||
elif HTTP_HEADER_HA_AUTH in self.headers:
|
elif HTTP_HEADER_HA_AUTH in self.headers:
|
||||||
api_password = self.headers.get(HTTP_HEADER_HA_AUTH)
|
api_password = self.headers.get(HTTP_HEADER_HA_AUTH)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user