Skip to content

Commit

Permalink
Require HTTPS in delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
nexy7574 committed Jun 26, 2024
1 parent ce8f47d commit 23f2252
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dendritecli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def resolve_delegation(self, domain: str) -> str:
parsed_url = urlparse(base_url)
if not parsed_url.netloc:
raise ValueError("Invalid URL in response.")
elif parsed_url.scheme != "https":
raise ValueError("URL must be HTTPS, got %r." % parsed_url.scheme)
try:
response = self.client.get(f"{base_url}/_matrix/client/versions")
response.raise_for_status()
Expand Down Expand Up @@ -395,7 +397,7 @@ def whois(self, user_id: str) -> dict:
user_id,
domain,
)
url = f"https://{self.resolve_delegation(domain)}{url}"
url = f"{self.resolve_delegation(domain)}{url}"

response = self.client.get(url)
log.info("Done fetching information about user %s", user_id)
Expand Down

0 comments on commit 23f2252

Please sign in to comment.