Skip to content

Commit 500e199

Browse files
committed
feat: redirect url takes base url from client for proxy use
1 parent 6cdc682 commit 500e199

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

custom_components/openid/authorize.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ window.fetch = async (...args) => {
2525
const urlParams = new URLSearchParams(window.location.search);
2626
const clientId = encodeURIComponent(urlParams.get('client_id'));
2727
const redirectUri = encodeURIComponent(urlParams.get('redirect_uri'));
28+
const baseUrl = window.location.origin;
2829

29-
window.location.href = `/auth/openid/authorize?client_id=${clientId}&redirect_uri=${redirectUri}`;
30+
const encodedUrl = encodeURIComponent(`/auth/openid/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&base_url=${baseUrl}`);
31+
window.location.href = decodeURIComponent(encodedUrl);
3032
};
3133

3234
listNode.appendChild(listItemNode);

custom_components/openid/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ async def get(self, request: Request) -> Response:
4747
state = secrets.token_urlsafe(24)
4848

4949
params = request.rel_url.query
50-
51-
redirect_uri = str(request.url.with_path("/auth/openid/callback"))
50+
base_url = params.get("base_url", "")
51+
redirect_uri = str(URL(base_url).with_path("/auth/openid/callback"))
5252

5353
self.hass.data["_openid_state"][state] = params
5454

0 commit comments

Comments
 (0)