GitHub login fixes:

- Allow for case insensitivity in the org name list
  - Remove the check for verified email addresses when under Enterprise; it isn't supported there.
This commit is contained in:
Joseph Schorr 2015-04-16 12:17:39 -04:00
parent f8c80f7d11
commit 3cd11c8f45
2 changed files with 11 additions and 4 deletions

View file

@ -45,7 +45,11 @@ class GithubOAuthConfig(OAuthConfig):
if not self.config.get('ORG_RESTRICT', False):
return None
return self.config.get('ALLOWED_ORGANIZATIONS', None)
allowed = self.config.get('ALLOWED_ORGANIZATIONS', None)
if allowed is None:
return None
return [org.lower() for org in allowed]
def _endpoint(self):
endpoint = self.config.get('GITHUB_ENDPOINT', 'https://github.com')
@ -53,6 +57,9 @@ class GithubOAuthConfig(OAuthConfig):
endpoint = endpoint + '/'
return endpoint
def is_enterprise(self):
return self._endpoint().find('.github.com') < 0
def authorize_endpoint(self):
return self._get_url(self._endpoint(), '/login/oauth/authorize') + '?'
@ -104,7 +111,7 @@ class GithubOAuthConfig(OAuthConfig):
def validate_organization(self, organization_id, http_client):
api_endpoint = self._api_endpoint()
org_endpoint = self._get_url(api_endpoint, 'orgs/%s' % organization_id)
org_endpoint = self._get_url(api_endpoint, 'orgs/%s' % organization_id.lower())
result = http_client.get(org_endpoint,
headers={'Accept': 'application/vnd.github.moondragon+json'},