1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Add .well-known/password-change (#39613)

This commit is contained in:
Paulus Schoutsen 2020-09-03 18:13:33 +02:00 committed by GitHub
parent 4ebcbadfc2
commit fbbfd46fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -284,6 +284,10 @@ async def async_setup(hass, config):
hass.http.register_static_path(
"/auth/authorize", str(root_path / "authorize.html"), False
)
# https://wicg.github.io/change-password-url/
hass.http.register_redirect(
"/.well-known/change-password", "/profile", redirect_exc=web.HTTPFound
)
local = hass.config.path("www")
if os.path.isdir(local):

View File

@ -345,7 +345,7 @@ class HomeAssistantHTTP:
view.register(self.app, self.app.router)
def register_redirect(self, url, redirect_to):
def register_redirect(self, url, redirect_to, *, redirect_exc=HTTPMovedPermanently):
"""Register a redirect with the server.
If given this must be either a string or callable. In case of a
@ -357,7 +357,7 @@ class HomeAssistantHTTP:
async def redirect(request):
"""Redirect to location."""
raise HTTPMovedPermanently(redirect_to)
raise redirect_exc(redirect_to)
self.app.router.add_route("GET", url, redirect)

View File

@ -484,3 +484,12 @@ async def test_get_version(hass, hass_ws_client):
assert msg["type"] == TYPE_RESULT
assert msg["success"]
assert msg["result"] == {"version": cur_version}
async def test_static_paths(hass, mock_http_client):
"""Test static paths."""
resp = await mock_http_client.get(
"/.well-known/change-password", allow_redirects=False
)
assert resp.status == 302
assert resp.headers["location"] == "/profile"