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:
parent
4ebcbadfc2
commit
fbbfd46fb8
@ -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):
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user