mirror of
https://github.com/home-assistant/core.git
synced 2025-08-30 09:51:37 +02:00
Pi_hole - Account for auth succeeding when it shouldn't (#150413)
This commit is contained in:
@@ -217,6 +217,13 @@ async def determine_api_version(
|
|||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Connection to %s failed: %s, trying API version 5", holeV6.base_url, ex_v6
|
"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")
|
holeV5 = api_by_version(hass, entry, 5, password="wrong_token")
|
||||||
try:
|
try:
|
||||||
await holeV5.get_data()
|
await holeV5.get_data()
|
||||||
|
@@ -221,12 +221,16 @@ def _create_mocked_hole(
|
|||||||
if wrong_host:
|
if wrong_host:
|
||||||
raise HoleConnectionError("Cannot authenticate with Pi-hole: err")
|
raise HoleConnectionError("Cannot authenticate with Pi-hole: err")
|
||||||
password = getattr(mocked_hole, "password", None)
|
password = getattr(mocked_hole, "password", None)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
raise_exception
|
raise_exception
|
||||||
or incorrect_app_password
|
or incorrect_app_password
|
||||||
|
or api_version == 5
|
||||||
or (api_version == 6 and password not in ["newkey", "apikey"])
|
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 HoleError("Authentication failed: Invalid password")
|
||||||
raise HoleConnectionError
|
raise HoleConnectionError
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user