Skip to content

Commit

Permalink
Only log change to use access token warning once (#15690)
Browse files Browse the repository at this point in the history
  • Loading branch information
awarecan authored and balloob committed Jul 27, 2018
1 parent a99b447 commit b2f4bbf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions homeassistant/components/http/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@
def setup_auth(app, trusted_networks, use_auth,
support_legacy=False, api_password=None):
"""Create auth middleware for the app."""
old_auth_warning = set()

@middleware
async def auth_middleware(request, handler):
"""Authenticate as middleware."""
authenticated = False

if use_auth and (HTTP_HEADER_HA_AUTH in request.headers or
DATA_API_PASSWORD in request.query):
_LOGGER.warning('Please change to use bearer token access %s',
request.path)
if request.path not in old_auth_warning:
_LOGGER.warning('Please change to use bearer token access %s',
request.path)
old_auth_warning.add(request.path)

legacy_auth = (not use_auth or support_legacy) and api_password
if (hdrs.AUTHORIZATION in request.headers and
Expand Down

0 comments on commit b2f4bbf

Please sign in to comment.