gitlab oauth
This commit is contained in:
parent
7426a540dd
commit
3ac884beb4
9 changed files with 88 additions and 14 deletions
|
@ -15,9 +15,6 @@ class OAuthConfig(object):
|
|||
def user_endpoint(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def login_endpoint(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def validate_client_id_and_secret(self, http_client):
|
||||
raise NotImplementedError
|
||||
|
||||
|
@ -200,4 +197,31 @@ class GoogleOAuthConfig(OAuthConfig):
|
|||
}
|
||||
|
||||
|
||||
class GitLabOAuthConfig(OAuthConfig):
|
||||
def __init__(self, config, key_name):
|
||||
super(GitLabOAuthConfig, self).__init__(config, key_name)
|
||||
|
||||
def _endpoint(self):
|
||||
endpoint = self.config.get('GITLAB_ENDPOINT', 'https://gitlab.com')
|
||||
if not endpoint.endswith('/'):
|
||||
endpoint = endpoint + '/'
|
||||
return endpoint
|
||||
|
||||
def service_name(self):
|
||||
return 'GitLab'
|
||||
|
||||
def authorize_endpoint(self):
|
||||
return self._get_url(self._endpoint(), '/oauth/authorize')
|
||||
|
||||
def token_endpoint(self):
|
||||
return self._get_url(self._endpoint(), '/oauth/token')
|
||||
|
||||
def validate_client_id_and_secret(self, http_client):
|
||||
pass
|
||||
|
||||
def get_public_config(self):
|
||||
return {
|
||||
'CLIENT_ID': self.client_id(),
|
||||
'AUTHORIZE_ENDPOINT': self.authorize_endpoint(),
|
||||
'GITLAB_ENDPOINT': self._endpoint(),
|
||||
}
|
||||
|
|
Reference in a new issue