From 61d1cbbea29b0d18b418268465feadb02af97a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Wed, 21 Aug 2024 11:19:48 +0200 Subject: [PATCH 1/2] No error on diff with the ending '/' --- src/simple_openid_connect/discovery.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/simple_openid_connect/discovery.py b/src/simple_openid_connect/discovery.py index efcb0fe..c8955bd 100644 --- a/src/simple_openid_connect/discovery.py +++ b/src/simple_openid_connect/discovery.py @@ -21,10 +21,8 @@ def discover_configuration_from_issuer(issuer: str) -> ProviderMetadata: :raises OpenidProtocolError: When the communication with the provider was not possible or the response was not in an expected format """ - if issuer.endswith("/"): - config_url = f"{issuer}.well-known/openid-configuration" - else: - config_url = f"{issuer}/.well-known/openid-configuration" + issuer = issuer.rstrip("/") + config_url = f"{issuer}/.well-known/openid-configuration" response = requests.get(config_url) if not utils.is_application_json(response.headers["Content-Type"]): @@ -35,7 +33,7 @@ def discover_configuration_from_issuer(issuer: str) -> ProviderMetadata: try: result = ProviderMetadata.parse_raw(response.content) - assert result.issuer == issuer, "issuer mismatch" + assert result.issuer.rstrip('/') == issuer, "issuer mismatch" except Exception as e: raise OpenidProtocolError( "The provider did not respond with a provider configuration according to spec" From bd1a81ecee1c1842849f9ddb4b54cd2ec330d888 Mon Sep 17 00:00:00 2001 From: ftsell Date: Thu, 22 Aug 2024 16:28:24 +0200 Subject: [PATCH 2/2] fix black formatting --- src/simple_openid_connect/discovery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simple_openid_connect/discovery.py b/src/simple_openid_connect/discovery.py index c8955bd..02b38ad 100644 --- a/src/simple_openid_connect/discovery.py +++ b/src/simple_openid_connect/discovery.py @@ -33,7 +33,7 @@ def discover_configuration_from_issuer(issuer: str) -> ProviderMetadata: try: result = ProviderMetadata.parse_raw(response.content) - assert result.issuer.rstrip('/') == issuer, "issuer mismatch" + assert result.issuer.rstrip("/") == issuer, "issuer mismatch" except Exception as e: raise OpenidProtocolError( "The provider did not respond with a provider configuration according to spec"