-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #201: Connection: don't send default auth headers to other domains
- Loading branch information
Showing
4 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
import warnings | ||
from pathlib import Path | ||
from typing import Dict, List, Tuple, Union, Callable, Optional, Any, Iterator | ||
from urllib.parse import urljoin | ||
from urllib.parse import urljoin, urlparse | ||
|
||
import requests | ||
from deprecated.sphinx import deprecated | ||
|
@@ -76,7 +76,9 @@ def request(self, method: str, path: str, headers: dict = None, auth: AuthBase = | |
check_error=True, expected_status=None, **kwargs): | ||
"""Generic request send""" | ||
url = self.build_url(path) | ||
auth = auth or self.auth | ||
# Don't send default auth headers to external domains. | ||
external = urlparse(url)[:2] != urlparse(self.root_url)[:2] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
soxofaan
Author
Member
|
||
auth = auth or (self.auth if not external else None) | ||
if _log.isEnabledFor(logging.DEBUG): | ||
_log.debug("Request `{m} {u}` with headers {h}, auth {a}, kwargs {k}".format( | ||
m=method.upper(), u=url, h=headers and headers.keys(), a=type(auth).__name__, k=list(kwargs.keys())) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@soxofaan Just found this via issue #201 and for the JS implementation, I'm wondering whether this should be different.
Wouldn't it be more correct to check something like
external = !url.startsWith(backendUrl)
(where backendUrl is the URL taken from well-known discovery likehttp://openeo.vito.be/v1.0/
. There could be rare cases where there are different services that are separated by folders, e.g. aws.com/sinergise vs. aws.com/vito (just as an example).