From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9BF277477E for ; Fri, 9 Jul 2021 13:42:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 99CC224BF4 for ; Fri, 9 Jul 2021 13:42:30 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 2891024BD6 for ; Fri, 9 Jul 2021 13:42:29 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 00F97406BF for ; Fri, 9 Jul 2021 13:42:29 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 9 Jul 2021 13:42:25 +0200 Message-Id: <20210709114226.269670-6-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210709114226.269670-1-d.csapak@proxmox.com> References: <20210709114226.269670-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.640 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [record.data] Subject: [pve-devel] [PATCH manager 1/2] ui: use AuthView and authSchema from widget-toolkit X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jul 2021 11:42:30 -0000 * moves the authSchema to the overrideAuthSchema call so that it can be found in Proxmox.Utils.authSchema instead. * changes the dc/AuthView to be a subclass of Proxmox.panel.AuthView with the necesary changes (onlinehelp, columns, etc.) * changes all calls from PVE.Utils.authSchema to Proxmox.Utils.authSchema Signed-off-by: Dominik Csapak --- www/manager6/Utils.js | 85 +++++++++++---------- www/manager6/Workspace.js | 2 +- www/manager6/dc/AuthEditBase.js | 2 +- www/manager6/dc/AuthView.js | 126 ++++++-------------------------- www/manager6/dc/UserView.js | 8 +- 5 files changed, 72 insertions(+), 151 deletions(-) diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index a22eaaa7..bf76e135 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -720,46 +720,6 @@ Ext.define('PVE.Utils', { return format === 'pbs-ct' || volid.match(':backup/vzdump-(lxc|openvz)-'); }, - authSchema: { - ad: { - name: gettext('Active Directory Server'), - ipanel: 'pveAuthADPanel', - syncipanel: 'pveAuthLDAPSyncPanel', - add: true, - tfa: true, - pwchange: true, - }, - ldap: { - name: gettext('LDAP Server'), - ipanel: 'pveAuthLDAPPanel', - syncipanel: 'pveAuthLDAPSyncPanel', - add: true, - tfa: true, - pwchange: true, - }, - openid: { - name: gettext('OpenID Connect Server'), - ipanel: 'pveAuthOpenIDPanel', - add: true, - tfa: false, - pwchange: false, - iconCls: 'pmx-itype-icon-openid-logo', - }, - pam: { - name: 'Linux PAM', - ipanel: 'pveAuthBasePanel', - add: false, - tfa: true, - pwchange: true, - }, - pve: { - name: 'Proxmox VE authentication server', - ipanel: 'pveAuthBasePanel', - add: false, - pwchange: true, - }, - }, - storageSchema: { dir: { name: Proxmox.Utils.directoryText, @@ -1851,6 +1811,51 @@ Ext.define('PVE.Utils', { vzumount: ['CT', gettext('Unmount')], zfscreate: [gettext('ZFS Storage'), gettext('Create')], }); + + Proxmox.Utils.overrideAuthSchema({ + ad: { + name: gettext('Active Directory Server'), + ipanel: 'pveAuthADPanel', + syncipanel: 'pveAuthLDAPSyncPanel', + add: true, + edit: true, + tfa: true, + pwchange: true, + }, + ldap: { + name: gettext('LDAP Server'), + ipanel: 'pveAuthLDAPPanel', + syncipanel: 'pveAuthLDAPSyncPanel', + add: true, + edit: true, + tfa: true, + pwchange: true, + }, + openid: { + name: gettext('OpenID Connect Server'), + ipanel: 'pveAuthOpenIDPanel', + add: true, + edit: true, + tfa: false, + pwchange: false, + iconCls: 'pmx-itype-icon-openid-logo', + }, + pam: { + name: 'Linux PAM', + ipanel: 'pveAuthBasePanel', + add: false, + edit: true, + tfa: true, + pwchange: true, + }, + pve: { + name: 'Proxmox VE authentication server', + ipanel: 'pveAuthBasePanel', + add: false, + edit: true, + pwchange: true, + }, + }); }, }); diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js index 0e2a750b..ad09f2b6 100644 --- a/www/manager6/Workspace.js +++ b/www/manager6/Workspace.js @@ -180,7 +180,7 @@ Ext.define('PVE.StdWorkspace', { let [_username, realm] = Proxmox.Utils.parse_userid(Proxmox.UserName); response.result.data.forEach((domain) => { if (domain.realm === realm) { - let schema = PVE.Utils.authSchema[domain.type]; + let schema = Proxmox.Utils.authSchema[domain.type]; if (schema) { me.query('#tfaitem')[0].setHidden(!schema.tfa); me.query('#passworditem')[0].setHidden(!schema.pwchange); diff --git a/www/manager6/dc/AuthEditBase.js b/www/manager6/dc/AuthEditBase.js index e18fbc3b..820b9966 100644 --- a/www/manager6/dc/AuthEditBase.js +++ b/www/manager6/dc/AuthEditBase.js @@ -24,7 +24,7 @@ Ext.define('PVE.panel.AuthBase', { initComponent: function() { let me = this; - let options = PVE.Utils.authSchema[me.type]; + let options = Proxmox.Utils.authSchema[me.type]; if (!me.column1) { me.column1 = []; } if (!me.column2) { me.column2 = []; } diff --git a/www/manager6/dc/AuthView.js b/www/manager6/dc/AuthView.js index 48a51015..aaad487d 100644 --- a/www/manager6/dc/AuthView.js +++ b/www/manager6/dc/AuthView.js @@ -1,17 +1,9 @@ Ext.define('PVE.dc.AuthView', { - extend: 'Ext.grid.GridPanel', - - alias: ['widget.pveAuthView'], + extend: 'Proxmox.panel.AuthView', + alias: 'widget.pveAuthView', onlineHelp: 'pveum_authentication_realms', - stateful: true, - stateId: 'grid-authrealms', - - viewConfig: { - trackOver: false, - }, - columns: [ { header: gettext('Realm'), @@ -40,101 +32,25 @@ Ext.define('PVE.dc.AuthView', { }, ], - store: { - model: 'pmx-domains', - sorters: { - property: 'realm', - order: 'DESC', - }, - }, - - openEditWindow: function(authType, realm) { - let me = this; - Ext.create('PVE.dc.AuthEditBase', { - authType, - realm, - listeners: { - destroy: () => me.reload(), - }, - }).show(); - }, - - reload: function() { - let me = this; - me.getStore().load(); - }, - - run_editor: function() { - let me = this; - let rec = me.getSelection()[0]; - if (!rec) { - return; - } - me.openEditWindow(rec.data.type, rec.data.realm); - }, - - open_sync_window: function() { - let me = this; - let rec = me.getSelection()[0]; - if (!rec) { - return; - } - Ext.create('PVE.dc.SyncWindow', { - realm: rec.data.realm, - listeners: { - destroy: () => me.reload(), - }, - }).show(); - }, - - initComponent: function() { - var me = this; - - let items = []; - for (const [authType, config] of Object.entries(PVE.Utils.authSchema)) { - if (!config.add) { continue; } - items.push({ - text: config.name, - iconCls: 'fa fa-fw ' + (config.iconCls || 'fa-address-book-o'), - handler: () => me.openEditWindow(authType), - }); - } - - Ext.apply(me, { - tbar: [ - { - text: gettext('Add'), - menu: { - items: items, + extraButtons: [ + { + xtype: 'proxmoxButton', + text: gettext('Sync'), + disabled: true, + enableFn: (rec) => Boolean(Proxmox.Utils.authSchema[rec.data.type].syncipanel), + handler: function() { + let panel = this.up('pveAuthView'); + let rec = panel.getSelection()[0]; + if (!rec) { + return; + } + Ext.create('PVE.dc.SyncWindow', { + realm: rec.data.realm, + listeners: { + destroy: () => panel.reload(), }, - }, - { - xtype: 'proxmoxButton', - text: gettext('Edit'), - disabled: true, - handler: () => me.run_editor(), - }, - { - xtype: 'proxmoxStdRemoveButton', - baseurl: '/access/domains/', - enableFn: (rec) => PVE.Utils.authSchema[rec.data.type].add, - callback: () => me.reload(), - }, - '-', - { - xtype: 'proxmoxButton', - text: gettext('Sync'), - disabled: true, - enableFn: (rec) => Boolean(PVE.Utils.authSchema[rec.data.type].syncipanel), - handler: () => me.open_sync_window(), - }, - ], - listeners: { - activate: () => me.reload(), - itemdblclick: () => me.run_editor(), + }).show(); }, - }); - - me.callParent(); - }, + }, + ], }); diff --git a/www/manager6/dc/UserView.js b/www/manager6/dc/UserView.js index ef394bdb..5fa01683 100644 --- a/www/manager6/dc/UserView.js +++ b/www/manager6/dc/UserView.js @@ -61,8 +61,8 @@ Ext.define('PVE.dc.UserView', { enableFn: function(record) { let type = record.data['realm-type']; if (type) { - if (PVE.Utils.authSchema[type]) { - return !!PVE.Utils.authSchema[type].pwchange; + if (Proxmox.Utils.authSchema[type]) { + return !!Proxmox.Utils.authSchema[type].pwchange; } } return false; @@ -84,8 +84,8 @@ Ext.define('PVE.dc.UserView', { enableFn: function(record) { let type = record.data['realm-type']; if (type) { - if (PVE.Utils.authSchema[type]) { - return !!PVE.Utils.authSchema[type].tfa; + if (Proxmox.Utils.authSchema[type]) { + return !!Proxmox.Utils.authSchema[type].tfa; } } return false; -- 2.30.2