1
mirror of https://github.com/home-assistant/core synced 2024-07-27 18:58:57 +02:00

Fix trusted networks auth provider warning message (#22671)

* Fix trusted networks auth provider warning message

* Update auth.py
This commit is contained in:
Jason Hu 2019-04-02 21:23:59 -07:00 committed by Paulus Schoutsen
parent f2941522ca
commit 6a411710df
2 changed files with 12 additions and 6 deletions

View File

@ -190,12 +190,16 @@ def setup_auth(hass, app):
elif (trusted_networks and
await async_validate_trusted_networks(request)):
_LOGGER.warning(
'Access from trusted networks without auth token is going to '
'be removed in Home Assistant 0.96. Configure the trusted '
'networks auth provider or use long-lived access tokens to '
'access %s from %s',
request.path, request[KEY_REAL_IP])
if request.path not in old_auth_warning:
# When removing this, don't forget to remove the print logic
# in http/view.py
request['deprecate_warning_message'] = \
'Access from trusted networks without auth token is ' \
'going to be removed in Home Assistant 0.96. Configure ' \
'the trusted networks auth provider or use long-lived ' \
'access tokens to access {} from {}'.format(
request.path, request[KEY_REAL_IP])
old_auth_warning.add(request.path)
authenticated = True
elif (support_legacy and HTTP_HEADER_HA_AUTH in request.headers and

View File

@ -98,6 +98,8 @@ def request_handler_factory(view, handler):
if view.requires_auth:
if authenticated:
if 'deprecate_warning_message' in request:
_LOGGER.warning(request['deprecate_warning_message'])
await process_success_login(request)
else:
raise HTTPUnauthorized()