Use HassKey for helpers (1) (#117012)
This commit is contained in:
parent
8f614fb06d
commit
2db64c7e6d
8 changed files with 68 additions and 48 deletions
|
@ -27,6 +27,7 @@ from homeassistant import config_entries
|
|||
from homeassistant.components import http
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.loader import async_get_application_credentials
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
from .aiohttp_client import async_get_clientsession
|
||||
from .network import NoURLAvailableError
|
||||
|
@ -34,8 +35,15 @@ from .network import NoURLAvailableError
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DATA_JWT_SECRET = "oauth2_jwt_secret"
|
||||
DATA_IMPLEMENTATIONS = "oauth2_impl"
|
||||
DATA_PROVIDERS = "oauth2_providers"
|
||||
DATA_IMPLEMENTATIONS: HassKey[dict[str, dict[str, AbstractOAuth2Implementation]]] = (
|
||||
HassKey("oauth2_impl")
|
||||
)
|
||||
DATA_PROVIDERS: HassKey[
|
||||
dict[
|
||||
str,
|
||||
Callable[[HomeAssistant, str], Awaitable[list[AbstractOAuth2Implementation]]],
|
||||
]
|
||||
] = HassKey("oauth2_providers")
|
||||
AUTH_CALLBACK_PATH = "/auth/external/callback"
|
||||
HEADER_FRONTEND_BASE = "HA-Frontend-Base"
|
||||
MY_AUTH_CALLBACK_PATH = "https://my.home-assistant.io/redirect/oauth"
|
||||
|
@ -398,10 +406,7 @@ async def async_get_implementations(
|
|||
hass: HomeAssistant, domain: str
|
||||
) -> dict[str, AbstractOAuth2Implementation]:
|
||||
"""Return OAuth2 implementations for specified domain."""
|
||||
registered = cast(
|
||||
dict[str, AbstractOAuth2Implementation],
|
||||
hass.data.setdefault(DATA_IMPLEMENTATIONS, {}).get(domain, {}),
|
||||
)
|
||||
registered = hass.data.setdefault(DATA_IMPLEMENTATIONS, {}).get(domain, {})
|
||||
|
||||
if DATA_PROVIDERS not in hass.data:
|
||||
return registered
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue