mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Move Local OAuth http endpoint registration to auth component (#69507)
This commit is contained in:
parent
8ef7ac1877
commit
c07100e519
@ -3,7 +3,7 @@
|
||||
"name": "Almond",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/almond",
|
||||
"dependencies": ["http", "conversation"],
|
||||
"dependencies": ["auth", "conversation"],
|
||||
"codeowners": ["@gcampax", "@balloob"],
|
||||
"requirements": ["pyalmond==0.0.2"],
|
||||
"iot_class": "local_polling",
|
||||
|
@ -113,6 +113,12 @@ Result will be a long-lived access token:
|
||||
"result": "ABCDEFGH"
|
||||
}
|
||||
|
||||
|
||||
# POST /auth/external/callback
|
||||
|
||||
This is an endpoint for OAuth2 Authorization callbacks used by integrations
|
||||
that link accounts with other cloud providers using LocalOAuth2Implementation
|
||||
as part of a config flow.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@ -134,6 +140,7 @@ from homeassistant.components.http.ban import log_invalid_auth
|
||||
from homeassistant.components.http.data_validator import RequestDataValidator
|
||||
from homeassistant.components.http.view import HomeAssistantView
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.config_entry_oauth2_flow import OAuth2AuthorizeCallbackView
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.loader import bind_hass
|
||||
from homeassistant.util import dt as dt_util
|
||||
@ -195,6 +202,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
|
||||
hass.http.register_view(TokenView(retrieve_result))
|
||||
hass.http.register_view(LinkUserView(retrieve_result))
|
||||
hass.http.register_view(OAuth2AuthorizeCallbackView())
|
||||
|
||||
websocket_api.async_register_command(
|
||||
hass, WS_TYPE_CURRENT_USER, websocket_current_user, SCHEMA_WS_CURRENT_USER
|
||||
|
@ -2,7 +2,7 @@
|
||||
"domain": "google",
|
||||
"name": "Google Calendars",
|
||||
"config_flow": true,
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"documentation": "https://www.home-assistant.io/integrations/calendar.google/",
|
||||
"requirements": [
|
||||
"google-api-python-client==2.38.0",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"domain": "home_connect",
|
||||
"name": "Home Connect",
|
||||
"documentation": "https://www.home-assistant.io/integrations/home_connect",
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"codeowners": ["@DavidMStraub"],
|
||||
"requirements": ["homeconnect==0.7.0"],
|
||||
"config_flow": true,
|
||||
|
@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/home_plus_control",
|
||||
"requirements": ["homepluscontrol==0.0.5"],
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"codeowners": ["@chemaaa"],
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["homepluscontrol"]
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "Honeywell Lyric",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/lyric",
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"requirements": ["aiolyric==1.0.8"],
|
||||
"codeowners": ["@timmo001"],
|
||||
"quality_scale": "silver",
|
||||
|
@ -5,7 +5,7 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/neato",
|
||||
"requirements": ["pybotvac==0.0.23"],
|
||||
"codeowners": ["@dshokouhi", "@Santobert"],
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["pybotvac"]
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
"domain": "nest",
|
||||
"name": "Nest",
|
||||
"config_flow": true,
|
||||
"dependencies": ["ffmpeg", "http"],
|
||||
"dependencies": ["ffmpeg", "http", "auth"],
|
||||
"after_dependencies": ["media_source"],
|
||||
"documentation": "https://www.home-assistant.io/integrations/nest",
|
||||
"requirements": ["python-nest==4.2.0", "google-nest-sdm==1.8.0"],
|
||||
|
@ -4,7 +4,7 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/netatmo",
|
||||
"requirements": ["pyatmo==6.2.4"],
|
||||
"after_dependencies": ["cloud", "media_source"],
|
||||
"dependencies": ["webhook"],
|
||||
"dependencies": ["auth", "webhook"],
|
||||
"codeowners": ["@cgtobi"],
|
||||
"config_flow": true,
|
||||
"homekit": {
|
||||
|
@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/ondilo_ico",
|
||||
"requirements": ["ondilo==0.2.0"],
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"codeowners": ["@JeromeHXP"],
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["ondilo"]
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "Smappee",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/smappee",
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"requirements": ["pysmappee==0.2.29"],
|
||||
"codeowners": ["@bsmappee"],
|
||||
"zeroconf": [
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "Somfy",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/somfy",
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"codeowners": ["@tetienne"],
|
||||
"requirements": ["pymfy==0.11.0"],
|
||||
"zeroconf": [
|
||||
|
@ -4,7 +4,7 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/spotify",
|
||||
"requirements": ["spotipy==2.19.0"],
|
||||
"zeroconf": ["_spotify-connect._tcp.local."],
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"codeowners": ["@frenck"],
|
||||
"config_flow": true,
|
||||
"quality_scale": "silver",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/toon",
|
||||
"requirements": ["toonapi==0.2.1"],
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"after_dependencies": ["cloud"],
|
||||
"codeowners": [],
|
||||
"dhcp": [
|
||||
|
@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/withings",
|
||||
"requirements": ["withings-api==2.4.0"],
|
||||
"dependencies": ["http", "webhook"],
|
||||
"dependencies": ["auth", "http", "webhook"],
|
||||
"codeowners": ["@vangorra"],
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["withings_api"]
|
||||
|
@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/xbox",
|
||||
"requirements": ["xbox-webapi==2.0.11"],
|
||||
"dependencies": ["http"],
|
||||
"dependencies": ["auth"],
|
||||
"codeowners": ["@hunterjm"],
|
||||
"iot_class": "cloud_polling"
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ from .network import NoURLAvailableError
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DATA_JWT_SECRET = "oauth2_jwt_secret"
|
||||
DATA_VIEW_REGISTERED = "oauth2_view_reg"
|
||||
DATA_IMPLEMENTATIONS = "oauth2_impl"
|
||||
DATA_PROVIDERS = "oauth2_providers"
|
||||
AUTH_CALLBACK_PATH = "/auth/external/callback"
|
||||
@ -331,12 +330,6 @@ def async_register_implementation(
|
||||
hass: HomeAssistant, domain: str, implementation: AbstractOAuth2Implementation
|
||||
) -> None:
|
||||
"""Register an OAuth2 flow implementation for an integration."""
|
||||
if isinstance(implementation, LocalOAuth2Implementation) and not hass.data.get(
|
||||
DATA_VIEW_REGISTERED, False
|
||||
):
|
||||
hass.http.register_view(OAuth2AuthorizeCallbackView())
|
||||
hass.data[DATA_VIEW_REGISTERED] = True
|
||||
|
||||
implementations = hass.data.setdefault(DATA_IMPLEMENTATIONS, {})
|
||||
implementations.setdefault(domain, {})[implementation.domain] = implementation
|
||||
|
||||
|
@ -173,7 +173,7 @@ def _custom_tasks(template, info: Info) -> None:
|
||||
)
|
||||
|
||||
elif template == "config_flow_oauth2":
|
||||
info.update_manifest(config_flow=True, dependencies=["http"])
|
||||
info.update_manifest(config_flow=True, dependencies=["auth"])
|
||||
info.update_strings(
|
||||
config={
|
||||
"step": {
|
||||
|
@ -26,7 +26,7 @@ TOKEN_URL = "https://example.como/auth/token"
|
||||
@pytest.fixture
|
||||
async def local_impl(hass):
|
||||
"""Local implementation."""
|
||||
assert await setup.async_setup_component(hass, "http", {})
|
||||
assert await setup.async_setup_component(hass, "auth", {})
|
||||
return config_entry_oauth2_flow.LocalOAuth2Implementation(
|
||||
hass, TEST_DOMAIN, CLIENT_ID, CLIENT_SECRET, AUTHORIZE_URL, TOKEN_URL
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user