Skip to content
Myr

Add trusted domains

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jake Treacher · committed by Jake Treacher · parent c9309e4 · Browse files · 1 file+8 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−1 removed

  • other:+8 added−1 removed

1 file+8 added−1 removed

modified:requests/sessions.py+8 added-1 removed
92 unmodified lines
939495class SessionRedirectMixin(object):9697 def __init__(self):98 #: A list of domains that will be excluded from auth stripping99 self.trusted_domains = []100101 def get_redirect_target(self, resp):102 """Receives a Response. Returns a redirect URI or ``None``"""103 # Due to the nature of how requests processes redirects this method will104 # be called at least once upon the original response and at least twice
17 unmodified lines
122 def should_strip_auth(self, old_url, new_url):123 """Decide whether Authorization header should be removed when redirecting"""124 old_parsed = urlparse(old_url)125 new_parsed = urlparse(new_url)122 if old_parsed.hostname != new_parsed.hostname:126 if (old_parsed.hostname != new_parsed.hostname127 and new_parsed.hostname not in self.trusted_domains):128 return True129 # Special case: allow http -> https redirect when using the standard130 # ports. This isn't specified by RFC 7235, but is kept to avoid131 # breaking backwards compatibility with older versions of requests
289 unmodified lines
421 self.adapters = OrderedDict()422 self.mount('https://', HTTPAdapter())423 self.mount('http://', HTTPAdapter())424425 super().__init__()426427 def __enter__(self):428 return self429430 def __exit__(self, *args):
347 unmodified lines