Use IndieAuth for client ID (#15369)
* Use IndieAuth for client ID * Lint * Lint & Fix tests * Allow local IP addresses * Update comment
This commit is contained in:
1 parent
f7d7d825b0
commit
0d4841cbea
14 files changed
+329
-347
No files matched your search
@@ -200,15 +200,6 @@ def add_manifest_json_key(key, val):
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Set up the serving of the frontend."""
|
||||
if hass.auth.active:
|
||||
client = await hass.auth.async_get_or_create_client(
|
||||
'Home Assistant Frontend',
|
||||
redirect_uris=['/'],
|
||||
no_secret=True,
|
||||
)
|
||||
else:
|
||||
client = None
|
||||
|
||||
hass.components.websocket_api.async_register_command(
|
||||
WS_TYPE_GET_PANELS, websocket_get_panels, SCHEMA_GET_PANELS)
|
||||
hass.components.websocket_api.async_register_command(
|
||||
@@ -255,7 +246,7 @@ async def async_setup(hass, config):
|
||||
if os.path.isdir(local):
|
||||
hass.http.register_static_path("/local", local, not is_dev)
|
||||
|
||||
index_view = IndexView(repo_path, js_version, client)
|
||||
index_view = IndexView(repo_path, js_version, hass.auth.active)
|
||||
hass.http.register_view(index_view)
|
||||
|
||||
@callback
|
||||
@@ -350,11 +341,11 @@ class IndexView(HomeAssistantView):
|
||||
requires_auth = False
|
||||
extra_urls = ['/states', '/states/{extra}']
|
||||
|
||||
def __init__(self, repo_path, js_option, client):
|
||||
def __init__(self, repo_path, js_option, auth_active):
|
||||
"""Initialize the frontend view."""
|
||||
self.repo_path = repo_path
|
||||
self.js_option = js_option
|
||||
self.client = client
|
||||
self.auth_active = auth_active
|
||||
self._template_cache = {}
|
||||
|
||||
def get_template(self, latest):
|
||||
@@ -399,11 +390,9 @@ class IndexView(HomeAssistantView):
|
||||
no_auth=no_auth,
|
||||
theme_color=MANIFEST_JSON['theme_color'],
|
||||
extra_urls=hass.data[extra_key],
|
||||
client_id=self.auth_active
|
||||
)
|
||||
|
||||
if self.client is not None:
|
||||
template_params['client_id'] = self.client.id
|
||||
|
||||
return web.Response(text=template.render(**template_params),
|
||||
content_type='text/html')
|
||||
|
||||
|
||||
Reference in new issue
Block a user