Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(oauth2): Manage OAuth2 and JWT plan security type
  • Loading branch information
brasseld committed Jan 24, 2018
1 parent 7205f26 commit 5aa30f8
Show file tree
Hide file tree
Showing 63 changed files with 3,097 additions and 959 deletions.
8 changes: 8 additions & 0 deletions docs/management-create-application.md
@@ -0,0 +1,8 @@
# Create application

An application is required to subscribe to API's plan. It is the intermediate link between a user (you) and an API
managed by someone else.


An application is a simple entity composed of small property which are mainly defined to describe the application
, what is does, ...
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -36,7 +36,7 @@
"bootstrap": "^3.3.7",
"codemirror": "^5.25.2",
"diff": "^3.2.0",
"dragular": "^4.3.0",
"dragular": "^4.4.6",
"highcharts": "^5.0.7",
"jquery": "^3.1.1",
"js-yaml": "^3.8.1",
Expand All @@ -47,7 +47,7 @@
"ng-file-upload": "^12.2.13",
"ng-infinite-scroll": "^1.3.0",
"ng-showdown": "^1.1.0",
"ngclipboard": "^1.1.1",
"ngclipboard": "^1.1.2",
"raml-1-parser": "^1.1.19 ",
"read-more": "0.0.0",
"satellizer": "^0.15.5",
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialog/confirm.dialog.html
Expand Up @@ -18,7 +18,7 @@
<md-dialog aria-label="confirm-dialog">
<md-dialog-content layout-padding>
<h4>{{title}}</h4>
<p>{{msg}}</p>
<p ng-bind-html="msg"></p>
</md-dialog-content>
<md-dialog-actions layout="row">
<md-button class="md-primary" ng-click="ctrl.cancel()">Cancel</md-button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialog/confirmWarning.dialog.html
Expand Up @@ -18,7 +18,7 @@
<md-dialog aria-label="warning-dialog">
<md-dialog-content layout-padding>
<h4>{{title}}</h4>
<p>{{msg}}</p>
<p ng-bind-html="msg"></p>
</md-dialog-content>
<md-dialog-actions layout="row">
<md-button class="md-primary" ng-click="ctrl.cancel()">Cancel</md-button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/widget/widget-data-table.component.ts
Expand Up @@ -70,7 +70,7 @@ const WidgetDataTableComponent: ng.IComponentOptions = {
if (this.widget.chart.link === 'api') {
this.$state.go('management.apis.detail.analytics', {apiId: key, from: this.widget.chart.request.from, to: this.widget.chart.request.to});
} else if (this.widget.chart.link === 'application') {
this.$state.go('management.applications.portal.analytics', {applicationId: key, from: this.widget.chart.request.from, to: this.widget.chart.request.to});
this.$state.go('management.applications.application.analytics', {applicationId: key, from: this.widget.chart.request.from, to: this.widget.chart.request.to});
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/index.scss
Expand Up @@ -41,6 +41,8 @@ $backgroundColor: rgb(45, 50, 62);
@import 'components/contextual/_contextual-doc.component.scss';
@import 'management/tasks/_tasks.scss';

$backgroundColor: rgb(45, 50, 62);

html {
font-family: 'Roboto Slab', serif;
}
Expand Down
2 changes: 1 addition & 1 deletion src/management/api/api-plan.html
Expand Up @@ -31,7 +31,7 @@ <h5 class="gravitee-plan-content">{{characteristic}}</h5>
<md-card-footer ng-if="$ctrl.authenticated">
<md-divider></md-divider>
<div layout="row" layout-align="end">
<md-button ng-if="$ctrl.plan.security === 'api_key' || $ctrl.plan.security === undefined" class="md-primary md-raised" aria-label="Execute"
<md-button ng-if="$ctrl.plan.security !== 'key_less' || $ctrl.plan.security === undefined" class="md-primary md-raised" aria-label="Execute"
ng-click="$ctrl.subscribe()" ng-disabled="!$ctrl.subscribable">
{{$ctrl.plan.alreadySubscribed ? 'Subscribed' : ($ctrl.plan.validation === 'auto'?'Subscribe': 'Request for subscription')}}
</md-button>
Expand Down
97 changes: 74 additions & 23 deletions src/management/api/apis.route.ts
Expand Up @@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ViewService from '../../services/view.service';
import ApisController from './apis.controller';
import TenantService from '../../services/tenant.service';
import ResourceService from '../../services/resource.service';
import TagService from '../../services/tag.service';
import ApiService from '../../services/api.service';
import MetadataService from '../../services/metadata.service';
import GroupService from '../../services/group.service';
import * as _ from 'lodash';
import ViewService from "../../services/view.service";
import ApisController from "./apis.controller";
import TenantService from "../../services/tenant.service";
import ResourceService from "../../services/resource.service";
import TagService from "../../services/tag.service";
import ApiService from "../../services/api.service";
import MetadataService from "../../services/metadata.service";
import GroupService from "../../services/group.service";
import * as _ from "lodash";
import AuditService from "../../services/audit.service";

export default apisRouterConfig;
Expand All @@ -35,7 +35,7 @@ function apisRouterConfig($stateProvider: ng.ui.IStateProvider) {
})
.state('management.apis.detail', {
abstract: true,
url: '/:apiId/settings',
url: '/:apiId',
template: require('./apiAdmin.html'),
controller: 'ApiAdminController',
controllerAs: 'apiCtrl',
Expand Down Expand Up @@ -227,14 +227,25 @@ function apisRouterConfig($stateProvider: ng.ui.IStateProvider) {
}
})
.state('management.apis.detail.plans', {
url: '/plans?state',
template: require('./plans/apiPlans.html'),
controller: 'ApiPlansController',
controllerAs: 'apiPlansCtrl',
abstract: true,
url: '/plans',
template: '<div layout="column"><div ui-view></div></div>',
resolve: {
resolvedPlans: function ($stateParams, ApiService) {
return ApiService.getApiPlans($stateParams.apiId);
api: ($stateParams: ng.ui.IStateParamsService, ApiService: ApiService) =>
ApiService.get($stateParams.apiId).then(response => response.data)
/*
groups: (GroupService: GroupService) => {
GroupService.list().then(response => response.data);
}
*/
}
})
.state('management.apis.detail.plans.list', {
url: '?state',
component: 'listPlans',
resolve: {
plans: ($stateParams: ng.ui.IStateParamsService, ApiService: ApiService) =>
ApiService.getApiPlans($stateParams.apiId).then(response => response.data)
},
data: {
menu: {
Expand All @@ -251,19 +262,43 @@ function apisRouterConfig($stateProvider: ng.ui.IStateProvider) {
params: {
state: {
type: 'string',
dynamic: true,
dynamic: true
}
}
})
.state('management.apis.detail.plans.new', {
url: '/new',
component: 'editPlan'
})
.state('management.apis.detail.plans.plan', {
url: '/:planId/edit',
component: 'editPlan',
resolve: {
plan: ($stateParams: ng.ui.IStateParamsService, ApiService: ApiService) =>
ApiService.getApiPlan($stateParams.apiId, $stateParams.planId).then(response => response.data)
}
})
.state('management.apis.detail.subscriptions', {
abstract: true,
url: '/subscriptions',
template: require('./subscriptions/subscriptions.html'),
controller: 'SubscriptionsController',
controllerAs: 'subscriptionsCtrl',
template: '<div layout="column"><div ui-view></div></div>',
resolve: {
resolvedSubscriptions: function ($stateParams, ApiService) {
return ApiService.getSubscriptions($stateParams.apiId);
}
api: ($stateParams: ng.ui.IStateParamsService, ApiService: ApiService) =>
ApiService.get($stateParams.apiId).then(response => response.data)
}
})
.state('management.apis.detail.subscriptions.list', {
url: '',
component: 'apiSubscriptions',
resolve: {
subscriptions: ($stateParams: ng.ui.IStateParamsService, ApiService: ApiService) =>
ApiService.getSubscriptions($stateParams.apiId).then(response => response.data),

subscribers: ($stateParams: ng.ui.IStateParamsService, ApiService: ApiService) =>
ApiService.getSubscribers($stateParams.apiId).then(response => response.data),

plans: ($stateParams: ng.ui.IStateParamsService, ApiService: ApiService) =>
ApiService.getApiPlans($stateParams.apiId).then(response => response.data)
},
data: {
menu: {
Expand All @@ -278,6 +313,22 @@ function apisRouterConfig($stateProvider: ng.ui.IStateProvider) {
}
}
})
.state('management.apis.detail.subscriptions.subscription', {
url: '/:subscriptionId',
component: 'apiSubscription',
resolve: {
subscription: ($stateParams: ng.ui.IStateParamsService, ApiService: ApiService) =>
ApiService.getSubscription($stateParams.apiId, $stateParams.subscriptionId).then(response => response.data)
},
data: {
perms: {
only: ['api-subscription-r']
},
docs: {
page: 'management-api-subscriptions'
}
}
})
.state('management.apis.detail.resources', {
url: '/resources',
template: require('./resources/resources.html'),
Expand Down
12 changes: 6 additions & 6 deletions src/management/api/plans/closePlan.dialog.html
Expand Up @@ -17,15 +17,15 @@
-->
<md-dialog aria-label="Close plan">
<md-dialog-content layout-padding>
<div ng-if="plan.security == 'api_key'">
<h4 ng-if="subscriptions == 0">No subscription is associated to this plan. You can delete it safely.</h4>
<h4 ng-if="subscriptions > 0">There are <code>{{subscriptions}}</code> active subscriptions associated to this plan.</h4>
<div ng-if="plan.security !== 'key_less'">
<h4 ng-if="subscriptions === 0">No subscription is associated to this plan. You can delete it safely.</h4>
<h4 ng-if="subscriptions > 0">There are <code>{{subscriptions}}</code> active subscription(s) associated to this plan.</h4>
<p ng-if="subscriptions > 0">
By closing this plan, all relative subscriptions will also be closed and associated api-keys will be no longer
available.
By closing this plan, all relative subscriptions will also be closed
<span ng-if="plan.security === 'api_key'"> and associated api-keys will be no longer available.</span>
</p>
</div>
<div ng-if="plan.security == 'key_less'">
<div ng-if="plan.security === 'key_less'">
<h4>Are you sure to close the plan {{plan.name}}?</h4>
</div>
</md-dialog-content>
Expand Down
2 changes: 1 addition & 1 deletion src/management/api/plans/closePlanDialog.controller.ts
Expand Up @@ -25,7 +25,7 @@ function DialogClosePlanController($scope, $rootScope, $mdDialog, ApiService, No
};

$scope.close = function () {
if ($scope.plan.security === 'api_key' && $scope.subscriptions === 0) {
if ($scope.plan.security !== 'key_less' && $scope.subscriptions === 0) {
ApiService.deletePlan($scope.apiId, $scope.plan.id).then(function() {
NotificationService.show('Plan ' + plan.name + ' has been deleted');
}).catch(function (error) {
Expand Down
24 changes: 24 additions & 0 deletions src/management/api/plans/list-plans.component.ts
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const ApiListPlansComponent: ng.IComponentOptions = {
bindings: {
plans: '<'
},
controller: 'ApiListPlansController',
template: require('./list-plans.html')
};

export default ApiListPlansComponent;

0 comments on commit 5aa30f8

Please sign in to comment.