Skip to content

Commit

Permalink
Merge pull request #354 from nvs-abhilash/github-tls-verify
Browse files Browse the repository at this point in the history
Respect validate_server_cert attribute for GitHub
  • Loading branch information
consideRatio committed May 16, 2020
2 parents aec2846 + c135d72 commit d2d3ac8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[flake8]
select = F
ignore = E,W,C,F401,F841
exclude = __init__.py
builtins =
c
get_config
exclude =
__init__.py
2 changes: 1 addition & 1 deletion docs/source/example-oauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def authenticate(self, handler, data=None):
),
)
else:
raise HTTPError(500, "Bad response: %s".format(resp))
raise HTTPError(500, "Bad response: {}".format(resp))

# Determine who the logged in user is
# by using the new access token to make a request
Expand Down
15 changes: 12 additions & 3 deletions oauthenticator/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ async def authenticate(self, handler, data=None):
method="POST",
headers={"Accept": "application/json"},
body='', # Body is required for a POST...
validate_cert=self.validate_server_cert,
)

resp = await http_client.fetch(req)
Expand All @@ -151,11 +152,14 @@ async def authenticate(self, handler, data=None):
),
)
else:
raise HTTPError(500, "Bad response: %s".format(resp))
raise HTTPError(500, "Bad response: {}".format(resp))

# Determine who the logged in user is
req = HTTPRequest(
self.github_api + "/user", method="GET", headers=_api_headers(access_token)
self.github_api + "/user",
method="GET",
headers=_api_headers(access_token),
validate_cert=self.validate_server_cert,
)
resp = await http_client.fetch(req)
resp_json = json.loads(resp.body.decode('utf8', 'replace'))
Expand Down Expand Up @@ -205,7 +209,12 @@ async def _check_organization_whitelist(self, org, username, access_token):
org,
username,
)
req = HTTPRequest(check_membership_url, method="GET", headers=headers)
req = HTTPRequest(
check_membership_url,
method="GET",
headers=headers,
validate_cert=self.validate_server_cert,
)
self.log.debug(
"Checking GitHub organization membership: %s in %s?", username, org
)
Expand Down

0 comments on commit d2d3ac8

Please sign in to comment.