Add .well-known/password-change (#39613)
This commit is contained in:
parent
4ebcbadfc2
commit
fbbfd46fb8
3 changed files with 15 additions and 2 deletions
|
@ -284,6 +284,10 @@ async def async_setup(hass, config):
|
||||||
hass.http.register_static_path(
|
hass.http.register_static_path(
|
||||||
"/auth/authorize", str(root_path / "authorize.html"), False
|
"/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")
|
local = hass.config.path("www")
|
||||||
if os.path.isdir(local):
|
if os.path.isdir(local):
|
||||||
|
|
|
@ -345,7 +345,7 @@ class HomeAssistantHTTP:
|
||||||
|
|
||||||
view.register(self.app, self.app.router)
|
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.
|
"""Register a redirect with the server.
|
||||||
|
|
||||||
If given this must be either a string or callable. In case of a
|
If given this must be either a string or callable. In case of a
|
||||||
|
@ -357,7 +357,7 @@ class HomeAssistantHTTP:
|
||||||
|
|
||||||
async def redirect(request):
|
async def redirect(request):
|
||||||
"""Redirect to location."""
|
"""Redirect to location."""
|
||||||
raise HTTPMovedPermanently(redirect_to)
|
raise redirect_exc(redirect_to)
|
||||||
|
|
||||||
self.app.router.add_route("GET", url, redirect)
|
self.app.router.add_route("GET", url, redirect)
|
||||||
|
|
||||||
|
|
|
@ -484,3 +484,12 @@ async def test_get_version(hass, hass_ws_client):
|
||||||
assert msg["type"] == TYPE_RESULT
|
assert msg["type"] == TYPE_RESULT
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
assert msg["result"] == {"version": cur_version}
|
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"
|
||||||
|
|
Loading…
Add table
Reference in a new issue