Use My Home Assistant for OAuth2 redirect callbacks (#72449)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Franck Nijhof 2022-05-25 04:00:36 +02:00 committed by GitHub
parent b9baaf573c
commit 38ad1ef233
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -37,6 +37,7 @@ DATA_IMPLEMENTATIONS = "oauth2_impl"
DATA_PROVIDERS = "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"
CLOCK_OUT_OF_SYNC_MAX_SEC = 20
@ -129,6 +130,9 @@ class LocalOAuth2Implementation(AbstractOAuth2Implementation):
@property
def redirect_uri(self) -> str:
"""Return the redirect uri."""
if "my" in self.hass.config.components:
return MY_AUTH_CALLBACK_PATH
if (req := http.current_request.get()) is None:
raise RuntimeError("No current request in context")