Skip to content

Commit

Permalink
Fix double slashes in openid-configuration URLs
Browse files Browse the repository at this point in the history
Avoid double slashes in the endpoint URLs returned by
`/.well-known/openid-configuration`, fixing a bug introduced in
Gafaelfawr 12.0.0. The stringification of the base URL now always
includes a trailing slash for URLs with no path, which resulted
in a doubled slash and an invalid URL.
  • Loading branch information
rra committed Nov 19, 2024
1 parent a72faf6 commit 564e7db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.d/20241118_171429_rra_DM_47646.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Bug fixes

- Avoid double slashes in the endpoint URLs returned by `/.well-known/openid-configuration`, fixing a bug introduced in Gafaelfawr 12.0.0.
2 changes: 1 addition & 1 deletion src/gafaelfawr/services/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_jwks(self) -> JWKS:

def get_openid_configuration(self) -> OIDCConfig:
"""Return the OpenID Connect configuration for the internal server."""
base_url = str(self._config.issuer)
base_url = str(self._config.issuer).rstrip("/")
return OIDCConfig(
issuer=base_url,
authorization_endpoint=base_url + "/auth/openid/login",
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/oidc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ async def test_well_known_oidc(
r = await client.get("/.well-known/openid-configuration")
assert r.status_code == 200

base_url = str(config.oidc_server.issuer)
base_url = str(config.oidc_server.issuer).rstrip("/")
assert r.json() == {
"issuer": base_url,
"authorization_endpoint": base_url + "/auth/openid/login",
Expand Down

0 comments on commit 564e7db

Please sign in to comment.