Pi_hole - Account for auth succeeding when it shouldn't (#150413)

This commit is contained in:
HarvsG
2025-08-13 19:53:21 +01:00
committed by GitHub
parent f7726a7563
commit bda82e19a5
2 changed files with 12 additions and 1 deletions

View File

@@ -217,6 +217,13 @@ async def determine_api_version(
_LOGGER.debug(
"Connection to %s failed: %s, trying API version 5", holeV6.base_url, ex_v6
)
else:
# It seems that occasionally the auth can succeed unexpectedly when there is a valid session
_LOGGER.warning(
"Authenticated with %s through v6 API, but succeeded with an incorrect password. This is a known bug",
holeV6.base_url,
)
return 6
holeV5 = api_by_version(hass, entry, 5, password="wrong_token")
try:
await holeV5.get_data()

View File

@@ -221,12 +221,16 @@ def _create_mocked_hole(
if wrong_host:
raise HoleConnectionError("Cannot authenticate with Pi-hole: err")
password = getattr(mocked_hole, "password", None)
if (
raise_exception
or incorrect_app_password
or api_version == 5
or (api_version == 6 and password not in ["newkey", "apikey"])
):
if api_version == 6:
if api_version == 6 and (
incorrect_app_password or password not in ["newkey", "apikey"]
):
raise HoleError("Authentication failed: Invalid password")
raise HoleConnectionError