mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Allow non-authenticated calls to supervisor logs during onboarding (#40617)
This commit is contained in:
parent
373a1cabe6
commit
953f6bad46
@ -34,6 +34,10 @@ NO_TIMEOUT = re.compile(
|
|||||||
r")$"
|
r")$"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
NO_AUTH_ONBOARDING = re.compile(
|
||||||
|
r"^(?:" r"|supervisor/logs" r"|snapshots/[^/]+/.+" r")$"
|
||||||
|
)
|
||||||
|
|
||||||
NO_AUTH = re.compile(
|
NO_AUTH = re.compile(
|
||||||
r"^(?:" r"|app/.*" r"|addons/[^/]+/logo" r"|addons/[^/]+/icon" r")$"
|
r"^(?:" r"|app/.*" r"|addons/[^/]+/logo" r"|addons/[^/]+/icon" r")$"
|
||||||
)
|
)
|
||||||
@ -149,7 +153,7 @@ def _get_timeout(path: str) -> int:
|
|||||||
|
|
||||||
def _need_auth(hass, path: str) -> bool:
|
def _need_auth(hass, path: str) -> bool:
|
||||||
"""Return if a path need authentication."""
|
"""Return if a path need authentication."""
|
||||||
if not async_is_onboarded(hass) and path.startswith("snapshots"):
|
if not async_is_onboarded(hass) and NO_AUTH_ONBOARDING.match(path):
|
||||||
return False
|
return False
|
||||||
if NO_AUTH.match(path):
|
if NO_AUTH.match(path):
|
||||||
return False
|
return False
|
||||||
|
@ -155,6 +155,8 @@ def test_need_auth(hass):
|
|||||||
"""Test if the requested path needs authentication."""
|
"""Test if the requested path needs authentication."""
|
||||||
assert not _need_auth(hass, "addons/test/logo")
|
assert not _need_auth(hass, "addons/test/logo")
|
||||||
assert _need_auth(hass, "snapshots/new/upload")
|
assert _need_auth(hass, "snapshots/new/upload")
|
||||||
|
assert _need_auth(hass, "supervisor/logs")
|
||||||
|
|
||||||
hass.data["onboarding"] = False
|
hass.data["onboarding"] = False
|
||||||
assert not _need_auth(hass, "snapshots/new/upload")
|
assert not _need_auth(hass, "snapshots/new/upload")
|
||||||
|
assert not _need_auth(hass, "supervisor/logs")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user