Skip to content

Commit

Permalink
Added GraphQL Credentials menus
Browse files Browse the repository at this point in the history
  • Loading branch information
elliatab committed Jun 19, 2019
1 parent 08c2f3c commit 33a45ce
Show file tree
Hide file tree
Showing 4 changed files with 276 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@
$scope.basic_auth_credentials;
$scope.hmac_auth_credentials;
$scope.oauth2_credentials;
$scope.gql_operation_whitelist;


$scope.credentialGroups = [
{
id: 'gql-op-whitelist',
name: 'OPERATION WHITELIST',
icon: 'mdi-fingerprint',
fetchFunc: fetchGQLWhitelist
},
{
id: 'basic-auth',
name: 'BASIC',
Expand Down Expand Up @@ -58,9 +66,9 @@
$scope.availablePlugins = $rootScope.Gateway.plugins.available_on_server;

// Remove credentials that are not available on the server
$scope.credentialGroups = _.filter($scope.credentialGroups, function (item) {
return $scope.availablePlugins[item.id];
})
// $scope.credentialGroups = _.filter($scope.credentialGroups, function (item) {
// return $scope.availablePlugins[item.id];
// })

// Fetch the remaining ones
$scope.credentialGroups.forEach(function (item) {
Expand All @@ -73,12 +81,14 @@
$scope.createApiKey = createApiKey
$scope.createJWT = createJWT
$scope.manageBasicAuth = manageBasicAuth
$scope.manageGraphQLOperation = manageGraphQLOperation
$scope.createOAuth2 = createOAuth2
$scope.createHMAC = createHMAC
$scope.deleteKey = deleteKey
$scope.deleteJWT = deleteJWT
$scope.deleteOAuth2 = deleteOAuth2
$scope.deleteBasicAuthCredentials = deleteBasicAuthCredentials
$scope.deleteGraphQLOperation = deleteGraphQLOperation
$scope.deleteHMACAuthCredentials = deleteHMACAuthCredentials
$scope.setActiveGroup = setActiveGroup;
$scope.filterGroup = filterGroup;
Expand Down Expand Up @@ -111,6 +121,24 @@
})
}

function deleteGraphQLOperation($index, operation) {
DialogService.prompt(
"Delete Operation", "Really want to delete the selected operation?",
['No don\'t', 'Yes! delete it'],
function accept() {
ConsumerService
.removeCredential($scope.consumer.id, 'gql-op-whitelist', operation.id)
.then(
function onSuccess(result) {
MessageService.success('Operation deleted successfully');
fetchGQLWhitelist()
}
)

}, function decline() {
})
}

function deleteBasicAuthCredentials($index, credentials) {
DialogService.prompt(
"Delete Credentials", "Really want to delete the selected credentials?",
Expand Down Expand Up @@ -199,6 +227,25 @@
});
}

function manageGraphQLOperation(operation) {
$uibModal.open({
animation: true,
ariaLabelledBy: 'modal-title',
ariaDescribedBy: 'modal-body',
templateUrl: 'js/app/consumers/credentials/manage-gql-op-whitelist-controller.html',
controller: 'ManageGqlOpWhitelistController',
controllerAs: '$ctrl',
resolve: {
_consumer: function () {
return $scope.consumer
},
_cred: function () {
return operation
}
}
});
}


function manageBasicAuth(cred) {
$uibModal.open({
Expand Down Expand Up @@ -283,6 +330,13 @@
})
}

function fetchGQLWhitelist() {
ConsumerService.loadCredentials($scope.consumer.id, 'gql-op-whitelist')
.then(function (res) {
console.log("FETCH GRAPHQL OP WHITELIST =>", res.data);
$scope.gql_operation_whitelist = res.data;
})
}

function fetchBasicAuthCredentials() {
ConsumerService.loadCredentials($scope.consumer.id, 'basic-auth')
Expand Down Expand Up @@ -333,6 +387,9 @@
* ----------------------------------------------------------
*/

$scope.$on('consumer.gql-op-whitelist.created', function (ev, group) {
fetchGQLWhitelist()
})

$scope.$on('consumer.key.created', function (ev, group) {
fetchKeys()
Expand Down
2 changes: 1 addition & 1 deletion config/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ module.exports.http = {
* since that's the only time Express will cache flat-files. *
* *
***************************************************************************/
cache: 31557600000
cache: 0
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 33a45ce

Please sign in to comment.