Add ability to one-click generate an authorization access token in the applications panel
This commit is contained in:
parent
ccc16fd6f4
commit
58ca76239b
8 changed files with 66 additions and 4 deletions
|
@ -4871,4 +4871,12 @@ i.slack-icon {
|
|||
#startTriggerDialog #runForm .field-title {
|
||||
width: 120px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
#gen-token table {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#gen-token input[type="checkbox"] {
|
||||
margin-right: 10px;
|
||||
}
|
|
@ -1711,6 +1711,12 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
|||
return notificationService;
|
||||
}]);
|
||||
|
||||
$provide.factory('OAuthService', ['$location', 'Config', function($location, Config) {
|
||||
var oauthService = {};
|
||||
oauthService.SCOPES = window.__auth_scopes;
|
||||
return oauthService;
|
||||
}]);
|
||||
|
||||
$provide.factory('KeyService', ['$location', 'Config', function($location, Config) {
|
||||
var keyService = {}
|
||||
var oauth = window.__oauth;
|
||||
|
|
|
@ -2676,12 +2676,28 @@ function OrgMemberLogsCtrl($scope, $routeParams, $rootScope, $timeout, Restangul
|
|||
}
|
||||
|
||||
|
||||
function ManageApplicationCtrl($scope, $routeParams, $rootScope, $location, $timeout, ApiService) {
|
||||
function ManageApplicationCtrl($scope, $routeParams, $rootScope, $location, $timeout, OAuthService, ApiService, UserService, Config) {
|
||||
var orgname = $routeParams.orgname;
|
||||
var clientId = $routeParams.clientid;
|
||||
|
||||
$scope.Config = Config;
|
||||
$scope.OAuthService = OAuthService;
|
||||
$scope.updating = false;
|
||||
|
||||
$scope.genScopes = {};
|
||||
|
||||
UserService.updateUserIn($scope);
|
||||
|
||||
$scope.getScopes = function(scopes) {
|
||||
var checked = [];
|
||||
for (var scopeName in scopes) {
|
||||
if (scopes.hasOwnProperty(scopeName) && scopes[scopeName]) {
|
||||
checked.push(scopeName);
|
||||
}
|
||||
}
|
||||
return checked;
|
||||
};
|
||||
|
||||
$scope.askResetClientSecret = function() {
|
||||
$('#resetSecretModal').modal({});
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<ul class="nav nav-pills nav-stacked">
|
||||
<li class="active"><a href="javascript:void(0)" data-toggle="tab" data-target="#settings">Settings</a></li>
|
||||
<li><a href="javascript:void(0)" data-toggle="tab" data-target="#oauth">OAuth Information</a></li>
|
||||
<li><a href="javascript:void(0)" data-toggle="tab" data-target="#gen-token">Generate Token</a></li>
|
||||
<li><a href="javascript:void(0)" data-toggle="tab" data-target="#delete">Delete Application</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -91,6 +92,30 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Generate Token tab -->
|
||||
<div id="gen-token" class="tab-pane">
|
||||
<div style="margin-bottom: 20px">
|
||||
Click the button below to generate a new <a href="http://tools.ietf.org/html/rfc6749#section-1.4" target="_new">OAuth 2 Access Token</a>.
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px">
|
||||
<strong>Note:</strong> The generated token will act on behalf of user <img src="//www.gravatar.com/avatar/{{ user.gravatar }}?s=16&d=identicon" style="margin-left: 6px; margin-right: 4px;">
|
||||
{{ user.username }}
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr ng-repeat="(scopeName, scopeInfo) in OAuthService.SCOPES">
|
||||
<td><label onclick="event.stopPropagation()"><input type="checkbox" value="scopeInfo[0]" ng-model="genScopes[scopeName]">{{ scopeInfo[3] }}</label></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<a class="btn btn-success"
|
||||
href="{{ Config.getUrl('/oauth/authorize?response_type=token&client_id=' + application.client_id + '&scope=' + getScopes(genScopes).join(',') + '&redirect_uri=display') }}"
|
||||
ng-disabled="!getScopes(genScopes).length" target="_blank">
|
||||
Generate Access Token
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- OAuth tab -->
|
||||
<div id="oauth" class="tab-pane">
|
||||
<table style="margin-top: 20px;">
|
||||
|
|
Reference in a new issue