Skip to content

Commit

Permalink
Remove legacy_api_password auth provider (#119976)
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus authored Jun 19, 2024
1 parent 7d14b9c commit bae008b
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 285 deletions.
123 changes: 0 additions & 123 deletions homeassistant/auth/providers/legacy_api_password.py

This file was deleted.

6 changes: 0 additions & 6 deletions homeassistant/components/auth/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,5 @@
"invalid_code": "Invalid code, please try again."
}
}
},
"issues": {
"deprecated_legacy_api_password": {
"title": "The legacy API password is deprecated",
"description": "The legacy API password authentication provider is deprecated and will be removed. Please remove it from your YAML configuration and use the default Home Assistant authentication provider instead."
}
}
}
1 change: 0 additions & 1 deletion pylint/plugins/hass_enforce_type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class ClassTypeHintMatch:
"hass_ws_client": "WebSocketGenerator",
"init_tts_cache_dir_side_effect": "Any",
"issue_registry": "IssueRegistry",
"legacy_auth": "LegacyApiPasswordAuthProvider",
"local_auth": "HassAuthProvider",
"mock_async_zeroconf": "MagicMock",
"mock_bleak_scanner_start": "MagicMock",
Expand Down
90 changes: 0 additions & 90 deletions tests/auth/providers/test_legacy_api_password.py

This file was deleted.

19 changes: 0 additions & 19 deletions tests/components/api/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

from homeassistant import const
from homeassistant.auth.models import Credentials
from homeassistant.auth.providers.legacy_api_password import (
LegacyApiPasswordAuthProvider,
)
from homeassistant.bootstrap import DATA_LOGGING
import homeassistant.core as ha
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -731,22 +728,6 @@ async def test_rendering_template_admin(
assert resp.status == HTTPStatus.UNAUTHORIZED


async def test_rendering_template_legacy_user(
hass: HomeAssistant,
mock_api_client: TestClient,
aiohttp_client: ClientSessionGenerator,
legacy_auth: LegacyApiPasswordAuthProvider,
) -> None:
"""Test rendering a template with legacy API password."""
hass.states.async_set("sensor.temperature", 10)
client = await aiohttp_client(hass.http.app)
resp = await client.post(
const.URL_API_TEMPLATE,
json={"template": "{{ states.sensor.temperature.state }}"},
)
assert resp.status == HTTPStatus.UNAUTHORIZED


async def test_api_call_service_not_found(
hass: HomeAssistant, mock_api_client: TestClient
) -> None:
Expand Down
20 changes: 5 additions & 15 deletions tests/components/http/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
from homeassistant.auth.const import GROUP_ID_READ_ONLY
from homeassistant.auth.models import User
from homeassistant.auth.providers import trusted_networks
from homeassistant.auth.providers.legacy_api_password import (
LegacyApiPasswordAuthProvider,
)
from homeassistant.auth.providers.homeassistant import HassAuthProvider
from homeassistant.components import websocket_api
from homeassistant.components.http import KEY_HASS
from homeassistant.components.http.auth import (
Expand Down Expand Up @@ -76,14 +74,6 @@ async def mock_handler(request):
return web.json_response(data={"user_id": user_id})


async def get_legacy_user(auth):
"""Get the user in legacy_api_password auth provider."""
provider = auth.get_auth_provider("legacy_api_password", None)
return await auth.async_get_or_create_user(
await provider.async_get_or_create_credentials({})
)


@pytest.fixture
def app(hass):
"""Fixture to set up a web.Application."""
Expand Down Expand Up @@ -126,7 +116,7 @@ async def test_auth_middleware_loaded_by_default(hass: HomeAssistant) -> None:
async def test_cant_access_with_password_in_header(
app,
aiohttp_client: ClientSessionGenerator,
legacy_auth: LegacyApiPasswordAuthProvider,
local_auth: HassAuthProvider,
hass: HomeAssistant,
) -> None:
"""Test access with password in header."""
Expand All @@ -143,7 +133,7 @@ async def test_cant_access_with_password_in_header(
async def test_cant_access_with_password_in_query(
app,
aiohttp_client: ClientSessionGenerator,
legacy_auth: LegacyApiPasswordAuthProvider,
local_auth: HassAuthProvider,
hass: HomeAssistant,
) -> None:
"""Test access with password in URL."""
Expand All @@ -164,7 +154,7 @@ async def test_basic_auth_does_not_work(
app,
aiohttp_client: ClientSessionGenerator,
hass: HomeAssistant,
legacy_auth: LegacyApiPasswordAuthProvider,
local_auth: HassAuthProvider,
) -> None:
"""Test access with basic authentication."""
await async_setup_auth(hass, app)
Expand Down Expand Up @@ -278,7 +268,7 @@ async def test_auth_active_access_with_trusted_ip(
async def test_auth_legacy_support_api_password_cannot_access(
app,
aiohttp_client: ClientSessionGenerator,
legacy_auth: LegacyApiPasswordAuthProvider,
local_auth: HassAuthProvider,
hass: HomeAssistant,
) -> None:
"""Test access using api_password if auth.support_legacy."""
Expand Down
6 changes: 2 additions & 4 deletions tests/components/http/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

import pytest

from homeassistant.auth.providers.legacy_api_password import (
LegacyApiPasswordAuthProvider,
)
from homeassistant.auth.providers.homeassistant import HassAuthProvider
from homeassistant.components import http
from homeassistant.core import HomeAssistant
from homeassistant.helpers.http import KEY_HASS
Expand Down Expand Up @@ -115,7 +113,7 @@ async def test_not_log_password(
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
caplog: pytest.LogCaptureFixture,
legacy_auth: LegacyApiPasswordAuthProvider,
local_auth: HassAuthProvider,
) -> None:
"""Test access with password doesn't get logged."""
assert await async_setup_component(hass, "api", {"http": {}})
Expand Down
8 changes: 3 additions & 5 deletions tests/components/websocket_api/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from aiohttp import WSMsgType
import pytest

from homeassistant.auth.providers.legacy_api_password import (
LegacyApiPasswordAuthProvider,
)
from homeassistant.auth.providers.homeassistant import HassAuthProvider
from homeassistant.components.websocket_api.auth import (
TYPE_AUTH,
TYPE_AUTH_INVALID,
Expand Down Expand Up @@ -51,7 +49,7 @@ def track_disconnected():
async def test_auth_events(
hass: HomeAssistant,
no_auth_websocket_client,
legacy_auth: LegacyApiPasswordAuthProvider,
local_auth: HassAuthProvider,
hass_access_token: str,
track_connected,
) -> None:
Expand Down Expand Up @@ -174,7 +172,7 @@ async def test_auth_active_with_password_not_allow(
async def test_auth_legacy_support_with_password(
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
legacy_auth: LegacyApiPasswordAuthProvider,
local_auth: HassAuthProvider,
) -> None:
"""Test authenticating with a token."""
assert await async_setup_component(hass, "websocket_api", {})
Expand Down
6 changes: 2 additions & 4 deletions tests/components/websocket_api/test_sensor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Test cases for the API stream sensor."""

from homeassistant.auth.providers.legacy_api_password import (
LegacyApiPasswordAuthProvider,
)
from homeassistant.auth.providers.homeassistant import HassAuthProvider
from homeassistant.bootstrap import async_setup_component
from homeassistant.components.websocket_api.auth import TYPE_AUTH_REQUIRED
from homeassistant.components.websocket_api.http import URL
Expand All @@ -17,7 +15,7 @@ async def test_websocket_api(
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
hass_access_token: str,
legacy_auth: LegacyApiPasswordAuthProvider,
local_auth: HassAuthProvider,
) -> None:
"""Test API streams."""
await async_setup_component(
Expand Down
Loading

0 comments on commit bae008b

Please sign in to comment.