You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/11/08 15:39:42 UTC

[GitHub] mitchell852 closed pull request #2911: Add ability to regenerate KSK keys in TP

mitchell852 closed pull request #2911: Add ability to regenerate KSK keys in TP
URL: https://github.com/apache/trafficcontrol/pull/2911
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/traffic_portal/app/src/app.js b/traffic_portal/app/src/app.js
index a33fc180a..0e0f5c96e 100644
--- a/traffic_portal/app/src/app.js
+++ b/traffic_portal/app/src/app.js
@@ -71,6 +71,7 @@ var trafficPortal = angular.module('trafficPortal', [
         require('./modules/private/cdns/deliveryServices').name,
         require('./modules/private/cdns/dnssecKeys').name,
         require('./modules/private/cdns/dnssecKeys/generate').name,
+        require('./modules/private/cdns/dnssecKeys/regenerateKsk').name,
         require('./modules/private/cdns/dnssecKeys/view').name,
         require('./modules/private/cdns/edit').name,
         require('./modules/private/cdns/federations').name,
@@ -251,6 +252,7 @@ var trafficPortal = angular.module('trafficPortal', [
         require('./common/modules/form/cdn/new').name,
         require('./common/modules/form/cdnDnssecKeys').name,
         require('./common/modules/form/cdnDnssecKeys/generate').name,
+        require('./common/modules/form/cdnDnssecKeys/regenerateKsk').name,
         require('./common/modules/form/coordinate').name,
         require('./common/modules/form/coordinate/edit').name,
         require('./common/modules/form/coordinate/new').name,
diff --git a/traffic_portal/app/src/common/api/CDNService.js b/traffic_portal/app/src/common/api/CDNService.js
index 2bf2d5970..8a6c0c2e8 100644
--- a/traffic_portal/app/src/common/api/CDNService.js
+++ b/traffic_portal/app/src/common/api/CDNService.js
@@ -240,6 +240,23 @@ var CDNService = function($http, $q, Restangular, locationUtils, messageModel, E
         return request.promise;
     };
 
+	this.regenerateKSK = function(kskRequest, cdnKey) {
+		var request = $q.defer();
+
+		$http.post(ENV.api['root'] + "cdns/" + cdnKey + "/dnsseckeys/ksk/generate", kskRequest)
+			.then(
+				function(result) {
+					request.resolve(result);
+				},
+				function(fault) {
+					messageModel.setMessages(fault.data.alerts, false);
+					request.reject();
+				}
+			);
+
+		return request.promise;
+	};
+
 };
 
 CDNService.$inject = ['$http', '$q', 'Restangular', 'locationUtils', 'messageModel', 'ENV'];
diff --git a/traffic_portal/app/src/common/modules/form/_form.scss b/traffic_portal/app/src/common/modules/form/_form.scss
index 0869e2f66..a0e1b65c1 100644
--- a/traffic_portal/app/src/common/modules/form/_form.scss
+++ b/traffic_portal/app/src/common/modules/form/_form.scss
@@ -22,4 +22,9 @@
 
 form .control-label > span:hover {
   text-decoration: underline;
+}
+
+.dnssec-info-text {
+  margin-bottom: 12px;
+  font-size: medium;
 }
\ No newline at end of file
diff --git a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/FormCdnDnssecKeysController.js b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/FormCdnDnssecKeysController.js
index effec2d0c..e2f79326c 100644
--- a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/FormCdnDnssecKeysController.js
+++ b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/FormCdnDnssecKeysController.js
@@ -19,9 +19,12 @@
 
 var FormCdnDnssecKeysController = function(cdn, dnssecKeys, $scope, $location, $uibModal, dateUtils, formUtils, stringUtils, locationUtils, messageModel) {
 
-	var generate = function() {
+	$scope.generate = function() {
 		$location.path($location.path() + '/generate');
 	};
+	$scope.regenerateKSK = function() {
+		$location.path($location.path() + '/regenerateKsk');
+	};
 
 	$scope.cdn = cdn;
 
@@ -40,36 +43,6 @@ var FormCdnDnssecKeysController = function(cdn, dnssecKeys, $scope, $location, $
 		return label;
 	};
 
-	$scope.confirmGenerate = function() {
-		var title = 'Generate DNSSEC Keys [ ' + cdn.name + ' ]',
-			msg = 'This will generate DNSSEC keys for the ' + cdn.name + ' CDN and all associated Delivery Services.<br><br>Are you sure you want to proceed?';
-
-		if ($scope.ksk_new) {
-			title = 'Regenerate DNSSEC Keys [ ' + cdn.name + ' ]';
-			msg = 'This will regenerate DNSSEC keys for the ' + cdn.name + ' CDN and all associated Delivery Services. A new DS Record will be created and needs to be added to the parent zone in order for DNSSEC to work properly.<br><br>Are you sure you want to proceed?';
-		}
-
-		var params = {
-			title: title,
-			message: msg
-		};
-		var modalInstance = $uibModal.open({
-			templateUrl: 'common/modules/dialog/confirm/dialog.confirm.tpl.html',
-			controller: 'DialogConfirmController',
-			size: 'md',
-			resolve: {
-				params: function () {
-					return params;
-				}
-			}
-		});
-		modalInstance.result.then(function() {
-			generate();
-		}, function () {
-			messageModel.setMessages([ { level: 'warning', text: title + ' cancelled' } ], false);
-		});
-	};
-
 	$scope.dateFormat = dateUtils.dateFormat;
 
 	$scope.navigateToPath = locationUtils.navigateToPath;
diff --git a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/form.cdnDnssecKeys.tpl.html b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/form.cdnDnssecKeys.tpl.html
index 2a81ccf28..ade936b32 100644
--- a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/form.cdnDnssecKeys.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/form.cdnDnssecKeys.tpl.html
@@ -25,7 +25,10 @@
             <li class="active">DNSSEC Keys</li>
         </ol>
         <div class="pull-right">
-            <button class="btn btn-primary" title="Generate DNSSEC Keys" ng-click="confirmGenerate()">{{generateLabel()}}</button>
+            <button class="btn btn-primary" title="Regenerate KSK" ng-click="regenerateKSK()" ng-show="ksk_new">Regenerate KSK</button>
+        </div>
+        <div class="pull-right">
+            <button class="btn btn-primary" title="Generate DNSSEC Keys" ng-click="generate()">{{generateLabel()}}</button>
         </div>
         <div class="clearfix"></div>
     </div>
diff --git a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/generate/FormGenerateCdnDnssecKeysController.js b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/generate/FormGenerateCdnDnssecKeysController.js
index aa23ba6fc..27559b8c0 100644
--- a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/generate/FormGenerateCdnDnssecKeysController.js
+++ b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/generate/FormGenerateCdnDnssecKeysController.js
@@ -39,6 +39,12 @@ var FormGenerateCdnDnssecKeysController = function(cdn, dnssecKeysRequest, $scop
 		return label;
 	};
 
+	$scope.msg = 'This will generate DNSSEC keys for the ' + cdn.name + ' CDN and all associated Delivery Services.';
+
+	if ($scope.ksk_new) {
+		$scope.msg = 'This will regenerate DNSSEC keys for the ' + cdn.name + ' CDN and all associated Delivery Services. A new DS Record will be created and needs to be added to the parent zone in order for DNSSEC to work properly.';
+	}
+
 	$scope.confirmGenerate = function() {
 		var title = 'Generate DNSSEC Keys [ ' + cdn.name + ' ]',
 			msg = 'This action CANNOT be undone. This will generate DNSSEC keys for the ' + cdn.name + ' CDN and all associated Delivery Services.<br><br>Please type in the name of the CDN to confirm.';
diff --git a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/generate/form.GenerateCdnDnssecKeys.tpl.html b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/generate/form.GenerateCdnDnssecKeys.tpl.html
index ec2205446..ef958ef68 100644
--- a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/generate/form.GenerateCdnDnssecKeys.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/generate/form.GenerateCdnDnssecKeys.tpl.html
@@ -23,12 +23,13 @@
             <li><a ng-click="navigateToPath('/cdns')">CDNs</a></li>
             <li><a ng-click="navigateToPath('/cdns/' + cdn.id)">{{cdn.name}}</a></li>
             <li><a ng-click="navigateToPath('/cdns/' + cdn.id + '/dnssec-keys')">DNSSEC Keys</a></li>
-            <li class="active">generate</li>
+            <li class="active">Generate</li>
         </ol>
         <div class="clearfix"></div>
     </div>
     <div class="x_content">
         <br>
+        <div class="col-md-2 col-sm-2 col-xs-12"></div><div class="dnssec-info-text col-md-10 col-sm-10 col-xs-12">{{msg}}</div>
         <form name="cdnGenerateDnssecKeysForm" class="form-horizontal form-label-left" novalidate>
             <div class="form-group">
                 <label class="control-label col-md-2 col-sm-2 col-xs-12">CDN *</label>
@@ -62,7 +63,7 @@
             </div>
 
             <div class="modal-footer">
-                <button type="button" class="btn btn-success" ng-disabled="cdnGenerateDnssecKeysForm.$invalid" ng-click="confirmGenerate()">Generate</button>
+                <button type="button" class="btn btn-success" ng-disabled="cdnGenerateDnssecKeysForm.$invalid" ng-click="confirmGenerate()">Regenerate</button>
             </div>
         </form>
     </div>
diff --git a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/FormRegenerateKskController.js b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/FormRegenerateKskController.js
new file mode 100644
index 000000000..94632c782
--- /dev/null
+++ b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/FormRegenerateKskController.js
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+var FormRegenerateKskController = function(cdn, dnssecKeysRequest, $scope, $location, $uibModal, formUtils, locationUtils, cdnService, messageModel) {
+
+	var generate = function() {
+		$scope.kskRequest.effectiveDate = moment($scope.kskRequest.effectiveDate).utc().format();
+		cdnService.regenerateKSK($scope.kskRequest, $scope.cdnKey)
+			.then(function(result) {
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/cdns/' + cdn.id + '/dnssec-keys');
+			});
+	};
+
+	$scope.cdn = cdn;
+	$scope.cdnKey = dnssecKeysRequest.key;
+	$scope.kskRequest = {
+		effectiveDate: dnssecKeysRequest.effectiveDate,
+		expirationDays: 365
+	};
+
+	$scope.generateLabel = function() {
+		var label = 'Regenerate KSK';
+		return label;
+	};
+	$scope.msg = 'This will regenerate KSK (key signing keys) for the ' + cdn.name + ' CDN.';
+
+	$scope.confirmGenerate = function() {
+		var title = 'Regenerate KSK (key signing keys) [ ' + cdn.name + ' ]',
+			msg = 'This action CANNOT be undone. This will regenerate KSK (key signing keys) for the ' + cdn.name + ' CDN.<br><br>Please type in the name of the CDN to confirm.';
+
+		var params = {
+			title: title,
+			message: msg,
+			key: cdn.name
+		};
+		var modalInstance = $uibModal.open({
+			templateUrl: 'common/modules/dialog/confirm/enter/dialog.confirm.enter.tpl.html',
+			controller: 'DialogConfirmEnterController',
+			size: 'md',
+			resolve: {
+				params: function () {
+					return params;
+				}
+			}
+		});
+		modalInstance.result.then(function() {
+			generate();
+		}, function () {
+			messageModel.setMessages([ { level: 'warning', text: title + ' cancelled' } ], false);
+		});
+	};
+
+	$scope.navigateToPath = locationUtils.navigateToPath;
+
+	$scope.hasError = formUtils.hasError;
+
+	$scope.hasPropertyError = formUtils.hasPropertyError;
+
+};
+
+FormRegenerateKskController.$inject = ['cdn', 'dnssecKeysRequest', '$scope', '$location', '$uibModal', 'formUtils', 'locationUtils', 'cdnService', 'messageModel'];
+module.exports = FormRegenerateKskController;
diff --git a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/form.RegenerateKsk.tpl.html b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/form.RegenerateKsk.tpl.html
new file mode 100644
index 000000000..03b1f6df0
--- /dev/null
+++ b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/form.RegenerateKsk.tpl.html
@@ -0,0 +1,62 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<div class="x_panel">
+    <div class="x_title">
+        <ol class="breadcrumb pull-left">
+            <li><a ng-click="navigateToPath('/cdns')">CDNs</a></li>
+            <li><a ng-click="navigateToPath('/cdns/' + cdn.id)">{{cdn.name}}</a></li>
+            <li><a ng-click="navigateToPath('/cdns/' + cdn.id + '/dnssec-keys')">DNSSEC Keys</a></li>
+            <li class="active">Regenerate KSK</li>
+        </ol>
+        <div class="clearfix"></div>
+    </div>
+    <div class="x_content">
+        <br>
+        <div class="col-md-2 col-sm-2 col-xs-12"></div><div class="dnssec-info-text col-md-10 col-sm-10 col-xs-12">{{msg}}</div>
+        <form name="cdnRegenerateKSKForm" class="form-horizontal form-label-left" novalidate>
+            <div class="form-group">
+                <label class="control-label col-md-2 col-sm-2 col-xs-12">CDN *</label>
+                <div class="col-md-10 col-sm-10 col-xs-12">
+                    <input name="key" class="form-control" ng-model="cdnKey" readonly>
+                </div>
+            </div>
+            <div class="form-group" ng-class="{'has-error': hasError(cdnRegenerateKSKForm.kskExpirationDays), 'has-feedback': hasError(cdnRegenerateKSKForm.kskExpirationDays)}">
+                <label class="control-label col-md-2 col-sm-2 col-xs-12">KSK Expiration (Days) *</label>
+                <div class="col-md-10 col-sm-10 col-xs-12">
+                    <input name="kskExpirationDays" type="number" class="form-control" ng-model="kskRequest.expirationDays" required autofocus>
+                    <small class="input-error" ng-show="hasPropertyError(cdnRegenerateKSKForm.expirationDays, 'required')">Required</small>
+                    <span ng-show="hasError(cdnRegenerateKSKForm.expirationDays)" class="form-control-feedback"><i class="fa fa-times"></i></span>
+                </div>
+            </div>
+            <div class="form-group" ng-class="{'has-error': hasError(cdnRegenerateKSKForm.effectiveDate), 'has-feedback': hasError(cdnRegenerateKSKForm.effectiveDate)}">
+                <label class="control-label col-md-2 col-sm-2 col-xs-12">Effective Date (UTC) *</label>
+                <div class="col-md-10 col-sm-10 col-xs-12">
+                    <input name="effectiveDate" type="text" class="form-control" ng-model="kskRequest.effectiveDate" required autofocus>
+                    <small class="input-error" ng-show="hasPropertyError(cdnRegenerateKSKForm.effectiveDate, 'required')">Required</small>
+                    <span ng-show="hasError(cdnRegenerateKSKForm.effectiveDate)" class="form-control-feedback"><i class="fa fa-times"></i></span>
+                </div>
+            </div>
+
+            <div class="modal-footer">
+                <button type="button" class="btn btn-success" ng-disabled="cdnRegenerateKSKForm.$invalid" ng-click="confirmGenerate()">Generate</button>
+            </div>
+        </form>
+    </div>
+</div>
diff --git a/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/index.js b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/index.js
new file mode 100644
index 000000000..f249bbb81
--- /dev/null
+++ b/traffic_portal/app/src/common/modules/form/cdnDnssecKeys/regenerateKsk/index.js
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+module.exports = angular.module('trafficPortal.form.cdnDnssecKeys.regenerateKsk', [])
+	.controller('FormRegenerateKskController', require('./FormRegenerateKskController'));
\ No newline at end of file
diff --git a/traffic_portal/app/src/modules/private/cdns/dnssecKeys/regenerateKsk/index.js b/traffic_portal/app/src/modules/private/cdns/dnssecKeys/regenerateKsk/index.js
new file mode 100644
index 000000000..dda36f1d8
--- /dev/null
+++ b/traffic_portal/app/src/modules/private/cdns/dnssecKeys/regenerateKsk/index.js
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+module.exports = angular.module('trafficPortal.private.cdns.dnssecKeys.regenerateKsk', [])
+	.config(function($stateProvider, $urlRouterProvider) {
+		$stateProvider
+			.state('trafficPortal.private.cdns.dnssecKeys.regenerateKsk', {
+				url: '/regenerateKsk',
+				views: {
+					cdnDnssecKeysContent: {
+						templateUrl: 'common/modules/form/cdnDnssecKeys/regenerateKsk/form.RegenerateKsk.tpl.html',
+						controller: 'FormRegenerateKskController',
+						resolve: {
+							cdn: function($stateParams, cdnService) {
+								return cdnService.getCDN($stateParams.cdnId);
+							},
+							dnssecKeysRequest: function(cdn) {
+								return {
+									key: cdn.name,
+									name: cdn.domainName,
+									ttl: 60,
+									kskExpirationDays: 365,
+									zskExpirationDays: 30,
+									effectiveDate: moment().utc().format('YYYY-MM-DD HH:mm:ss')
+								};
+							}
+						}
+					}
+				}
+			})
+		;
+		$urlRouterProvider.otherwise('/');
+	});
diff --git a/traffic_portal/app/src/scripts/config.js b/traffic_portal/app/src/scripts/config.js
index 221da7bac..c7fce2cf4 100644
--- a/traffic_portal/app/src/scripts/config.js
+++ b/traffic_portal/app/src/scripts/config.js
@@ -23,6 +23,6 @@
 
 angular.module('config', [])
 
-.constant('ENV', { api: { root:'/api/1.3/' } })
+.constant('ENV', { api: { root:'/api/1.4/' } })
 
 ;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services