Skip to content

Commit

Permalink
Merge PR "No error on diff with the ending '/'"
Browse files Browse the repository at this point in the history
See #22
  • Loading branch information
ftsell committed Aug 22, 2024
2 parents 8cabeef + bd1a81e commit c140769
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/simple_openid_connect/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]):
Expand All @@ -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"
Expand Down

0 comments on commit c140769

Please sign in to comment.