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 F11AE698DC for ; Thu, 24 Mar 2022 13:46:01 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E5A142FFC8 for ; Thu, 24 Mar 2022 13:45:31 +0100 (CET) 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 05CF92FFBD for ; Thu, 24 Mar 2022 13:45:30 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id CC6BA42063 for ; Thu, 24 Mar 2022 13:45:29 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Thu, 24 Mar 2022 13:45:23 +0100 Message-Id: <20220324124524.3633145-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220324124524.3633145-1-d.csapak@proxmox.com> References: <20220324124524.3633145-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.149 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [result.data] Subject: [pve-devel] [PATCH manager v3 1/1] ui: realm sync: replace 'full' and 'purge' with 'remove-vanished' 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: Thu, 24 Mar 2022 12:46:02 -0000 in default sync options and the sync window. We do this by exposing the individual flags as checkboxes. We get the mapped value from the backend so we do not have to handle 'old' values here. Signed-off-by: Dominik Csapak --- www/manager6/dc/AuthEditLDAP.js | 63 +++++++++++++++++++------------ www/manager6/dc/SyncWindow.js | 66 ++++++++++++++++++++------------- 2 files changed, 80 insertions(+), 49 deletions(-) diff --git a/www/manager6/dc/AuthEditLDAP.js b/www/manager6/dc/AuthEditLDAP.js index 015a5a6e..50505ae2 100644 --- a/www/manager6/dc/AuthEditLDAP.js +++ b/www/manager6/dc/AuthEditLDAP.js @@ -100,7 +100,7 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', { xtype: 'pveAuthLDAPSyncPanel', editableAttributes: ['email'], - editableDefaults: ['scope', 'full', 'enable-new', 'purge'], + editableDefaults: ['scope', 'enable-new'], default_opts: {}, sync_attributes: {}, @@ -116,6 +116,15 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', { delete me.default_opts[attr]; } }); + let vanished_opts = []; + ['acl', 'entry', 'properties'].forEach((prop) => { + if (values[`remove-vanished-${prop}`]) { + vanished_opts.push(prop); + } + delete values[`remove-vanished-${prop}`]; + }); + me.default_opts['remove-vanished'] = vanished_opts.join(';'); + values['sync-defaults-options'] = PVE.Parser.printPropertyString(me.default_opts); me.editableAttributes.forEach((attr) => { if (values[attr]) { @@ -156,6 +165,13 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', { values[attr] = me.default_opts[attr]; } }); + + if (me.default_opts['remove-vanished']) { + let opts = me.default_opts['remove-vanished'].split(';'); + for (const opt of opts) { + values[`remove-vanished-${opt}`] = 1; + } + } } return me.callParent([values]); }, @@ -204,18 +220,6 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', { ['both', gettext('Users and Groups')], ], }, - { - xtype: 'proxmoxKVComboBox', - value: '__default__', - deleteEmpty: false, - comboItems: [ - ['__default__', Proxmox.Utils.NoneText], - ['1', Proxmox.Utils.yesText], - ['0', Proxmox.Utils.noText], - ], - name: 'full', - fieldLabel: gettext('Full'), - }, ], column2: [ @@ -269,17 +273,30 @@ Ext.define('PVE.panel.LDAPSyncInputPanel', { name: 'enable-new', fieldLabel: gettext('Enable new users'), }, + ], + + columnB: [ { - xtype: 'proxmoxKVComboBox', - value: '__default__', - deleteEmpty: false, - comboItems: [ - ['__default__', Proxmox.Utils.NoneText], - ['1', Proxmox.Utils.yesText], - ['0', Proxmox.Utils.noText], - ], - name: 'purge', - fieldLabel: gettext('Purge'), + xtype: 'displayfield', + fieldLabel: gettext('Remove Vanished'), + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('ACL'), + name: 'remove-vanished-acl', + boxLabel: gettext('Remove ACLs of users and groups which are not in the sync response.'), + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('Entry'), + name: 'remove-vanished-entry', + boxLabel: gettext('Remove users and groups that are not in the sync response.'), + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('Properties'), + name: 'remove-vanished-properties', + boxLabel: gettext('Remove user-properties that are not in the sync response.'), }, ], }); diff --git a/www/manager6/dc/SyncWindow.js b/www/manager6/dc/SyncWindow.js index 25a42182..b32926dd 100644 --- a/www/manager6/dc/SyncWindow.js +++ b/www/manager6/dc/SyncWindow.js @@ -32,6 +32,18 @@ Ext.define('PVE.dc.SyncWindow', { let view = me.getView(); let ipanel = me.lookup('ipanel'); let params = ipanel.getValues(); + + let vanished_opts = []; + ['acl', 'entry', 'properties'].forEach((prop) => { + if (params[`remove-vanished-${prop}`]) { + vanished_opts.push(prop); + } + delete params[`remove-vanished-${prop}`]; + }); + if (vanished_opts.length > 0) { + params['remove-vanished'] = vanished_opts.join(';'); + } + params['dry-run'] = is_preview ? 1 : 0; Proxmox.Utils.API2Request({ url: `/access/domains/${view.realm}/sync`, @@ -88,19 +100,6 @@ Ext.define('PVE.dc.SyncWindow', { ['both', gettext('Users and Groups')], ], }, - { - xtype: 'proxmoxKVComboBox', - value: '', - emptyText: gettext('No default available'), - deleteEmpty: false, - allowBlank: false, - comboItems: [ - ['1', Proxmox.Utils.yesText], - ['0', Proxmox.Utils.noText], - ], - name: 'full', - fieldLabel: gettext('Full'), - }, ], column2: [ @@ -116,22 +115,31 @@ Ext.define('PVE.dc.SyncWindow', { name: 'enable-new', fieldLabel: gettext('Enable new'), }, - { - xtype: 'proxmoxKVComboBox', - value: '', - emptyText: gettext('No default available'), - deleteEmpty: false, - allowBlank: false, - comboItems: [ - ['1', Proxmox.Utils.yesText], - ['0', Proxmox.Utils.noText], - ], - name: 'purge', - fieldLabel: gettext('Purge ACLs'), - }, ], columnB: [ + { + xtype: 'displayfield', + fieldLabel: gettext('Remove Vanished'), + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('ACL'), + name: 'remove-vanished-acl', + boxLabel: gettext('Remove ACLs of users and groups which are not in the sync response.'), + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('Entry'), + name: 'remove-vanished-entry', + boxLabel: gettext('Remove users and groups that are not in the sync response.'), + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('Properties'), + name: 'remove-vanished-properties', + boxLabel: gettext('Remove user-properties that are not in the sync response.'), + }, { xtype: 'displayfield', reference: 'defaulthint', @@ -183,6 +191,12 @@ Ext.define('PVE.dc.SyncWindow', { let default_options = response.result.data['sync-defaults-options']; if (default_options) { let options = PVE.Parser.parsePropertyString(default_options); + if (options['remove-vanished']) { + let opts = options['remove-vanished'].split(';'); + for (const opt of opts) { + options[`remove-vanished-${opt}`] = 1; + } + } let ipanel = me.lookup('ipanel'); ipanel.setValues(options); } else { -- 2.30.2