Make sure the external login link for GHE links to the enterprise GitHub and not the hosted version
This commit is contained in:
parent
d7efb7cf7a
commit
9d1b6d829a
5 changed files with 28 additions and 11 deletions
|
@ -180,10 +180,7 @@ def render_page_template(name, **kwargs):
|
||||||
def get_oauth_config():
|
def get_oauth_config():
|
||||||
oauth_config = {}
|
oauth_config = {}
|
||||||
for oauth_app in oauth_apps:
|
for oauth_app in oauth_apps:
|
||||||
oauth_config[oauth_app.key_name] = {
|
oauth_config[oauth_app.key_name] = oauth_app.get_public_config()
|
||||||
'CLIENT_ID': oauth_app.client_id(),
|
|
||||||
'AUTHORIZE_ENDPOINT': oauth_app.authorize_endpoint()
|
|
||||||
}
|
|
||||||
|
|
||||||
return oauth_config
|
return oauth_config
|
||||||
|
|
||||||
|
|
|
@ -1727,6 +1727,8 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
keyService['githubLoginUrl'] = oauth['GITHUB_LOGIN_CONFIG']['AUTHORIZE_ENDPOINT'];
|
keyService['githubLoginUrl'] = oauth['GITHUB_LOGIN_CONFIG']['AUTHORIZE_ENDPOINT'];
|
||||||
keyService['googleLoginUrl'] = oauth['GOOGLE_LOGIN_CONFIG']['AUTHORIZE_ENDPOINT'];
|
keyService['googleLoginUrl'] = oauth['GOOGLE_LOGIN_CONFIG']['AUTHORIZE_ENDPOINT'];
|
||||||
|
|
||||||
|
keyService['githubEndpoint'] = oauth['GITHUB_LOGIN_CONFIG']['GITHUB_ENDPOINT'];
|
||||||
|
|
||||||
keyService['githubTriggerAuthorizeUrl'] = oauth['GITHUB_LOGIN_CONFIG']['AUTHORIZE_ENDPOINT'];
|
keyService['githubTriggerAuthorizeUrl'] = oauth['GITHUB_LOGIN_CONFIG']['AUTHORIZE_ENDPOINT'];
|
||||||
|
|
||||||
keyService['githubLoginScope'] = 'user:email';
|
keyService['githubLoginScope'] = 'user:email';
|
||||||
|
|
|
@ -1738,6 +1738,7 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use
|
||||||
if (login.service == 'github') {
|
if (login.service == 'github') {
|
||||||
$scope.hasGithubLogin = true;
|
$scope.hasGithubLogin = true;
|
||||||
$scope.githubLogin = login.metadata['service_username'];
|
$scope.githubLogin = login.metadata['service_username'];
|
||||||
|
$scope.githubEndpoint = KeyService['githubEndpoint'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (login.service == 'google') {
|
if (login.service == 'google') {
|
||||||
|
|
|
@ -176,7 +176,7 @@
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div ng-show="hasGithubLogin && githubLogin" class="lead col-md-8">
|
<div ng-show="hasGithubLogin && githubLogin" class="lead col-md-8">
|
||||||
<i class="fa fa-github fa-lg" style="margin-right: 6px;" data-title="GitHub" bs-tooltip="tooltip.title"></i>
|
<i class="fa fa-github fa-lg" style="margin-right: 6px;" data-title="GitHub" bs-tooltip="tooltip.title"></i>
|
||||||
<b><a href="https://github.com/{{githubLogin}}" target="_blank">{{githubLogin}}</a></b>
|
<b><a href="{{githubEndpoint}}{{githubLogin}}" target="_blank">{{githubLogin}}</a></b>
|
||||||
<span class="delete-ui" button-title="'Detach'" delete-title="'Detach Account'" style="margin-left: 10px"
|
<span class="delete-ui" button-title="'Detach'" delete-title="'Detach Account'" style="margin-left: 10px"
|
||||||
perform-delete="detachExternalLogin('github')"></span>
|
perform-delete="detachExternalLogin('github')"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -37,17 +37,20 @@ class GithubOAuthConfig(OAuthConfig):
|
||||||
def service_name(self):
|
def service_name(self):
|
||||||
return 'GitHub'
|
return 'GitHub'
|
||||||
|
|
||||||
def authorize_endpoint(self):
|
def _endpoint(self):
|
||||||
endpoint = self.config.get('GITHUB_ENDPOINT', 'https://github.com')
|
endpoint = self.config.get('GITHUB_ENDPOINT', 'https://github.com')
|
||||||
return self._get_url(endpoint, '/login/oauth/authorize') + '?'
|
if not endpoint.endswith('/'):
|
||||||
|
endpoint = endpoint + '/'
|
||||||
|
return endpoint
|
||||||
|
|
||||||
|
def authorize_endpoint(self):
|
||||||
|
return self._get_url(self._endpoint(), '/login/oauth/authorize') + '?'
|
||||||
|
|
||||||
def token_endpoint(self):
|
def token_endpoint(self):
|
||||||
endpoint = self.config.get('GITHUB_ENDPOINT', 'https://github.com')
|
return self._get_url(self._endpoint(), '/login/oauth/access_token')
|
||||||
return self._get_url(endpoint, '/login/oauth/access_token')
|
|
||||||
|
|
||||||
def _api_endpoint(self):
|
def _api_endpoint(self):
|
||||||
endpoint = self.config.get('GITHUB_ENDPOINT', 'https://github.com')
|
return self.config.get('API_ENDPOINT', self._get_url(self._endpoint(), '/api/v3/'))
|
||||||
return self.config.get('API_ENDPOINT', self._get_url(endpoint, '/api/v3/'))
|
|
||||||
|
|
||||||
def user_endpoint(self):
|
def user_endpoint(self):
|
||||||
api_endpoint = self._api_endpoint()
|
api_endpoint = self._api_endpoint()
|
||||||
|
@ -57,6 +60,14 @@ class GithubOAuthConfig(OAuthConfig):
|
||||||
api_endpoint = self._api_endpoint()
|
api_endpoint = self._api_endpoint()
|
||||||
return self._get_url(api_endpoint, 'user/emails')
|
return self._get_url(api_endpoint, 'user/emails')
|
||||||
|
|
||||||
|
def get_public_config(self):
|
||||||
|
return {
|
||||||
|
'CLIENT_ID': self.client_id(),
|
||||||
|
'AUTHORIZE_ENDPOINT': self.authorize_endpoint(),
|
||||||
|
'GITHUB_ENDPOINT': self._endpoint()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GoogleOAuthConfig(OAuthConfig):
|
class GoogleOAuthConfig(OAuthConfig):
|
||||||
def __init__(self, app, key_name):
|
def __init__(self, app, key_name):
|
||||||
|
@ -74,5 +85,11 @@ class GoogleOAuthConfig(OAuthConfig):
|
||||||
def user_endpoint(self):
|
def user_endpoint(self):
|
||||||
return 'https://www.googleapis.com/oauth2/v1/userinfo'
|
return 'https://www.googleapis.com/oauth2/v1/userinfo'
|
||||||
|
|
||||||
|
def get_public_config(self):
|
||||||
|
return {
|
||||||
|
'CLIENT_ID': self.client_id(),
|
||||||
|
'AUTHORIZE_ENDPOINT': self.authorize_endpoint()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue