Skip to content

Commit 30ef2ed

Browse files
authored
OIDC: Use BASE_URL for redirect URI (#713)
* Use BASE_URL for redirect URI * Remove copilot change
1 parent 6558eb3 commit 30ef2ed

File tree

2 files changed

+176
-84
lines changed

2 files changed

+176
-84
lines changed

gramps_webapi/api/resources/oidc.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
redirect,
3232
render_template,
3333
request,
34-
url_for,
3534
)
3635
from marshmallow import EXCLUDE
3736
from webargs import fields
@@ -95,9 +94,10 @@ def get(self, args):
9594
500, f"OIDC client for provider '{provider_id}' not found"
9695
)
9796

98-
# Build redirect URI with provider parameter
99-
redirect_uri = url_for(
100-
"api.oidccallbackresource", provider=provider_id, _external=True
97+
# Build redirect URI with provider parameter using BASE_URL
98+
base_url = get_config("BASE_URL")
99+
redirect_uri = (
100+
f"{base_url.rstrip('/')}/api/oidc/callback/?provider={provider_id}"
101101
)
102102

103103
authorization_url = oidc_client.authorize_redirect(redirect_uri)
@@ -339,6 +339,7 @@ def get(self):
339339
return {"enabled": False}
340340

341341
# Build provider list with display information
342+
base_url = get_config("BASE_URL")
342343
providers = []
343344
for provider_id in available_providers:
344345
provider_config = get_provider_config(provider_id)
@@ -347,11 +348,7 @@ def get(self):
347348
{
348349
"id": provider_id,
349350
"name": provider_config["name"],
350-
"login_url": url_for(
351-
"api.oidcloginresource",
352-
provider=provider_id,
353-
_external=True,
354-
),
351+
"login_url": f"{base_url.rstrip('/')}/api/oidc/login/?provider={provider_id}",
355352
}
356353
)
357354

0 commit comments

Comments
 (0)