Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making requests_client.py's Authenticator URL matches() port-tolerant #384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions bravado/requests_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class Authenticator(object):
"""Authenticates requests.

:param host: Host to authenticate for.
:param host: Host to authenticate for. In some case
"""

def __init__(self, host):
Expand All @@ -33,10 +33,11 @@ def matches(self, url):
"""Returns true if this authenticator applies to the given url.

:param url: URL to check.
:return: True if matches host, port and scheme, False otherwise.
:return: True if matches host, False otherwise.
"""
host_without_port = self.host.split(':')[0]
split = urlparse.urlsplit(url)
return self.host == split.hostname
return host_without_port == split.hostname

def apply(self, request):
"""Apply authentication to a request.
Expand Down