You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2018/06/27 14:49:40 UTC
[13/50] [abbrv] ignite git commit: IGNITE-8428 Web Console:
Implemented connection to secured cluster.
http://git-wip-us.apache.org/repos/asf/ignite/blob/523a871b/modules/web-console/frontend/app/modules/agent/components/cluster-login/service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/components/cluster-login/service.js b/modules/web-console/frontend/app/modules/agent/components/cluster-login/service.js
new file mode 100644
index 0000000..a066bcf
--- /dev/null
+++ b/modules/web-console/frontend/app/modules/agent/components/cluster-login/service.js
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+import _ from 'lodash';
+
+import {ClusterSecrets} from '../../types/ClusterSecrets';
+import {CancellationError} from 'app/errors/CancellationError';
+
+export default class ClusterLoginService {
+ static $inject = ['$modal', '$q'];
+
+ constructor($modal, $q) {
+ this.$modal = $modal;
+ this.$q = $q;
+ }
+
+ /**
+ * @param {ClusterSecrets} baseSecrets
+ * @return {ng.IDifferend<ClusterSecrets>}
+ */
+ askCredentials(baseSecrets) {
+ const deferred = this.$q.defer();
+
+ const modal = this.$modal({
+ template: `
+ <cluster-login
+ secrets='$ctrl.secrets'
+ on-login='$ctrl.onLogin()'
+ on-hide='$ctrl.onHide()'
+ ></cluster-login>
+ `,
+ controller: [function() {
+ this.secrets = _.clone(baseSecrets);
+
+ this.onLogin = () => {
+ deferred.resolve(this.secrets);
+ };
+
+ this.onHide = () => {
+ deferred.reject(new CancellationError());
+ };
+ }],
+ controllerAs: '$ctrl',
+ backdrop: 'static',
+ show: true
+ });
+
+ return modal.$promise
+ .then(() => deferred.promise)
+ .finally(modal.hide);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/523a871b/modules/web-console/frontend/app/modules/agent/components/cluster-login/template.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/components/cluster-login/template.pug b/modules/web-console/frontend/app/modules/agent/components/cluster-login/template.pug
new file mode 100644
index 0000000..d1bfe18
--- /dev/null
+++ b/modules/web-console/frontend/app/modules/agent/components/cluster-login/template.pug
@@ -0,0 +1,56 @@
+//-
+ 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.
+
+include /app/helpers/jade/mixins
+
+.modal.modal--ignite.theme--ignite(tabindex='-1' role='dialog')
+ .modal-dialog
+ -var form = '$ctrl.form'
+
+ form.modal-content(name=form novalidate ng-submit='$ctrl.login()')
+ .modal-header
+ h4.modal-title
+ i.icon-confirm
+ span Enter cluster credentials
+ button.close(type='button' aria-label='Close' ng-click='$ctrl.onHide()')
+ svg(ignite-icon="cross")
+ .modal-body
+ .row
+ .col-50
+ +form-field__text({
+ label: 'User:',
+ model: '$ctrl.secrets.user',
+ name: '"user"',
+ placeholder: 'Input user',
+ required: true
+ })(
+ ng-model-options='{allowInvalid: true}'
+ autocomplete='node-user'
+ ignite-auto-focus
+ )
+ .col-50
+ +form-field__password({
+ label: 'Password:',
+ model: '$ctrl.secrets.password',
+ name: '"password"',
+ placeholder: 'Input password',
+ required: true
+ })(
+ autocomplete='node-password'
+ )
+ .modal-footer
+ button#btn-cancel.btn-ignite.btn-ignite--link-success(type='button' ng-click='$ctrl.onHide()') Cancel
+ button#btn-login.btn-ignite.btn-ignite--success Login
http://git-wip-us.apache.org/repos/asf/ignite/blob/523a871b/modules/web-console/frontend/app/modules/agent/types/Cluster.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/types/Cluster.js b/modules/web-console/frontend/app/modules/agent/types/Cluster.js
new file mode 100644
index 0000000..dd05405
--- /dev/null
+++ b/modules/web-console/frontend/app/modules/agent/types/Cluster.js
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+class Cluster {
+ /** @type {String} */
+ id;
+
+ /** @type {String} */
+ name;
+
+ /** @type {Boolean} */
+ connected = true;
+
+ /** @type {Boolean} */
+ secured;
+
+ constructor({id, name, secured = false}) {
+ this.id = id;
+ this.name = name;
+ this.secured = secured;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/523a871b/modules/web-console/frontend/app/modules/agent/types/ClusterSecrets.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/types/ClusterSecrets.js b/modules/web-console/frontend/app/modules/agent/types/ClusterSecrets.js
new file mode 100644
index 0000000..edff351
--- /dev/null
+++ b/modules/web-console/frontend/app/modules/agent/types/ClusterSecrets.js
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+import {nonEmpty} from 'app/utils/lodashMixins';
+
+export class ClusterSecrets {
+ /** @type {String} */
+ user;
+
+ /** @type {String} */
+ password;
+
+ /** @type {String} */
+ sessionToken;
+
+ constructor() {
+ this.user = 'ignite';
+ }
+
+ hasCredentials() {
+ return nonEmpty(this.user) && nonEmpty(this.password);
+ }
+
+ resetCredentials() {
+ this.resetSessionToken();
+
+ this.password = null;
+ }
+
+ resetSessionToken() {
+ this.sessionToken = null;
+ }
+
+ /**
+ * @return {{sessionToken: String}|{'user': String, 'password': String}}
+ */
+ getCredentials() {
+ const { sessionToken } = this;
+
+ if (sessionToken)
+ return { sessionToken };
+
+ const { user, password } = this;
+
+ return { user, password };
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/523a871b/modules/web-console/frontend/app/modules/agent/types/ClusterSecretsManager.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/types/ClusterSecretsManager.js b/modules/web-console/frontend/app/modules/agent/types/ClusterSecretsManager.js
new file mode 100644
index 0000000..f5bd5ac
--- /dev/null
+++ b/modules/web-console/frontend/app/modules/agent/types/ClusterSecretsManager.js
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+import {ClusterSecrets} from './ClusterSecrets';
+
+export class ClusterSecretsManager {
+ /** @type {Map<String, ClusterSecrets>} */
+ memoryCache = new Map();
+
+ /**
+ * @param {String} clusterId
+ * @private
+ */
+ _has(clusterId) {
+ return this.memoryCache.has(clusterId);
+ }
+
+ /**
+ * @param {String} clusterId
+ * @private
+ */
+ _get(clusterId) {
+ return this.memoryCache.get(clusterId);
+ }
+
+ /**
+ * @param {String} clusterId
+ */
+ get(clusterId) {
+ if (this._has(clusterId))
+ return this._get(clusterId);
+
+ const secrets = new ClusterSecrets();
+
+ this.put(clusterId, secrets);
+
+ return secrets;
+ }
+
+ /**
+ * @param {String} clusterId
+ * @param {ClusterSecrets} secrets
+ */
+ put(clusterId, secrets) {
+ this.memoryCache.set(clusterId, secrets);
+ }
+
+ /**
+ * @param {String} clusterId
+ */
+ reset(clusterId) {
+ const secrets = this._get(clusterId);
+
+ secrets && secrets.resetCredentials();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/523a871b/modules/web-console/frontend/app/utils/SimpleWorkerPool.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/utils/SimpleWorkerPool.js b/modules/web-console/frontend/app/utils/SimpleWorkerPool.js
index 495a4d2..8e7aab7 100644
--- a/modules/web-console/frontend/app/utils/SimpleWorkerPool.js
+++ b/modules/web-console/frontend/app/utils/SimpleWorkerPool.js
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+import _ from 'lodash';
+
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import 'rxjs/add/observable/race';