From 47fb3bdd336015df4075cb549a60662bd410e8ca Mon Sep 17 00:00:00 2001 From: Michael Manganiello Date: Wed, 8 Jan 2025 01:30:35 -0300 Subject: [PATCH] fix: Do not fail when OIDC server application URL has a trailing slash Use `authlib` util `get_well_known_url` to get the well-known URL for the OIDC server metadata. This will ensure that the URL is correctly formatted and does not fail when the OIDC server application URL has a trailing slash. Fixes #1430. --- backend/decorators/auth.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/decorators/auth.py b/backend/decorators/auth.py index e0013991d..f5b604ed7 100644 --- a/backend/decorators/auth.py +++ b/backend/decorators/auth.py @@ -1,6 +1,7 @@ from typing import Any from authlib.integrations.starlette_client import OAuth +from authlib.oidc.discovery import get_well_known_url from config import ( OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, @@ -49,7 +50,9 @@ name="openid", client_id=config.get("OIDC_CLIENT_ID"), client_secret=config.get("OIDC_CLIENT_SECRET"), - server_metadata_url=f'{config.get("OIDC_SERVER_APPLICATION_URL")}/.well-known/openid-configuration', + server_metadata_url=get_well_known_url( + config.get("OIDC_SERVER_APPLICATION_URL"), external=True + ), client_kwargs={"scope": "openid profile email"}, )