Skip to content

Commit

Permalink
Fix trusted networks auth provider warning message (home-assistant#22671
Browse files Browse the repository at this point in the history
)

* Fix trusted networks auth provider warning message

* Update auth.py
  • Loading branch information
awarecan authored and balloob committed Apr 3, 2019
1 parent f294152 commit 6a41171
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 10 additions & 6 deletions homeassistant/components/http/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,16 @@ async def auth_middleware(request, handler):

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
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/http/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ async def handle(request):

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()
Expand Down

0 comments on commit 6a41171

Please sign in to comment.