From 668b18e79eea68227372451fa90ad1415222d8d3 Mon Sep 17 00:00:00 2001 From: Jason Hu Date: Thu, 26 Jul 2018 07:29:24 -0700 Subject: [PATCH] Only log change to use access token warning once --- homeassistant/components/http/auth.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/http/auth.py b/homeassistant/components/http/auth.py index 4c71504104e4a..77621e3bc7c21 100644 --- a/homeassistant/components/http/auth.py +++ b/homeassistant/components/http/auth.py @@ -20,6 +20,8 @@ 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.""" @@ -27,8 +29,10 @@ async def auth_middleware(request, handler): 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