mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Only log change to use access token warning once (#15690)
This commit is contained in:
parent
a99b4472a8
commit
b2f4bbf93b
@ -20,6 +20,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
def setup_auth(app, trusted_networks, use_auth,
|
def setup_auth(app, trusted_networks, use_auth,
|
||||||
support_legacy=False, api_password=None):
|
support_legacy=False, api_password=None):
|
||||||
"""Create auth middleware for the app."""
|
"""Create auth middleware for the app."""
|
||||||
|
old_auth_warning = set()
|
||||||
|
|
||||||
@middleware
|
@middleware
|
||||||
async def auth_middleware(request, handler):
|
async def auth_middleware(request, handler):
|
||||||
"""Authenticate as middleware."""
|
"""Authenticate as middleware."""
|
||||||
@ -27,8 +29,10 @@ def setup_auth(app, trusted_networks, use_auth,
|
|||||||
|
|
||||||
if use_auth and (HTTP_HEADER_HA_AUTH in request.headers or
|
if use_auth and (HTTP_HEADER_HA_AUTH in request.headers or
|
||||||
DATA_API_PASSWORD in request.query):
|
DATA_API_PASSWORD in request.query):
|
||||||
_LOGGER.warning('Please change to use bearer token access %s',
|
if request.path not in old_auth_warning:
|
||||||
request.path)
|
_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
|
legacy_auth = (not use_auth or support_legacy) and api_password
|
||||||
if (hdrs.AUTHORIZATION in request.headers and
|
if (hdrs.AUTHORIZATION in request.headers and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user