]> git.proxmox.com Git - pmg-gui.git/commitdiff
Add DKIM Tab to MailProxy configuration
authorStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 21 Oct 2019 17:23:38 +0000 (19:23 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 23 Oct 2019 09:51:26 +0000 (11:51 +0200)
This adds another panel to the MailProxy configuration for DKIM-Settings.
Additionally the index-template now includes the css-file from
proxmox-widget-toolkit (for the pmx-hint user-class), needed in the
Settings-panel.

The Panel consists of 2 Grids:
* DKIM Settings
* DKIM Domains

DKIMDomains is a list of domain, currently like RelayDomains (hence the
code-reuse).

The DKIM settings grid binds to the dkim-related settings in pmg.conf, but the
edit-window for the selector uses the /config/dkim/selector route in the
PMG-API.

Additionally 2 checks for invalid configurations are excluded (you cannot
enable DKIM-Signing without creating a private key first)

The warnings were inspired by PVE's handling of EFIDisks and BIOS.

Finally the 'View DNS Record' button displays the DKIM TXT record for the
current key in the same format that opendkim-genkey writes it out.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
js/DKIMSettings.js [new file with mode: 0644]
js/MailProxyConfiguration.js
js/MailProxyDKIMPanel.js [new file with mode: 0644]
js/Makefile
pmg-index.html.tt

diff --git a/js/DKIMSettings.js b/js/DKIMSettings.js
new file mode 100644 (file)
index 0000000..a92a033
--- /dev/null
@@ -0,0 +1,201 @@
+Ext.define('PMG.DKIMEnableEdit', {
+    extend: 'Proxmox.window.Edit',
+    xtype: 'pmgDKIMEnableEdit',
+
+    items: [
+       {
+           xtype: 'displayfield',
+           userCls: 'pmx-hint',
+           value: gettext('You need to create a Selector before enabling DKIM Signing'),
+           hidden: true
+       },
+       {
+           xtype: 'proxmoxcheckbox',
+           name: 'dkim_sign',
+           uncheckedValue: 0,
+           defaultValue: 0,
+           checked: false,
+           deleteDefaultValue: false,
+           fieldLabel: gettext('Sign Outgoing Mails'),
+       }
+    ],
+    listeners: {
+       'show': function() {
+           var me = this;
+           var disablefn = function(errormsg){
+               Ext.Msg.alert(gettext('Error'), errormsg);
+               me.down('displayfield').setVisible(true);
+               me.down('proxmoxcheckbox').setDisabled(true);
+               me.close();
+           };
+
+           Proxmox.Utils.API2Request({
+               url : '/config/dkim/selector',
+               method : 'GET',
+               failure : function(response, opts) {
+                   disablefn(response.htmlStatus)
+               },
+               success : function(response, opts) {
+                   if (!Ext.isDefined(response.result.data.record)) {
+                       disablefn('Could not read private key - please create a selector first!');
+                   }
+               }
+           });
+       }
+    }
+});
+
+Ext.define('PMG.SelectorViewer', {
+    extend: 'Proxmox.window.Edit',
+    xtype: 'pmgDKIMSelectorView',
+
+    url: '/config/dkim/selector',
+    title: gettext('Selector'),
+
+    width: 800,
+    resizable: true,
+
+    items: [
+       {
+           xtype: 'displayfield',
+           fieldLabel: gettext('Selector'),
+           name: 'selector'
+       },
+       {
+           xtype: 'displayfield',
+           fieldLabel: gettext('Key Size'),
+           name: 'keysize'
+       },
+       {
+           xtype: 'textarea',
+           editable: false,
+           grow: true,
+           growMin: 150,
+           growMax: 400,
+           fieldLabel: gettext('DNS TXT Record'),
+           name: 'record',
+           value: 'Could not read private key!'
+       }
+    ],
+
+    initComponent: function() {
+       var me = this;
+
+       me.callParent();
+
+       // hide OK/Reset button, because we just want to show data
+       me.down('toolbar[dock=bottom]').setVisible(false);
+    }
+});
+
+Ext.define('PMG.DKIMSettings', {
+    extend: 'Proxmox.grid.ObjectGrid',
+    xtype: 'pmgDKIM',
+
+    monStoreErrors: true,
+
+    initComponent : function() {
+       var me = this;
+
+       me.rows = {};
+       var enable_sign_text = gettext('Enable DKIM Signing');
+       me.rows.dkim_sign = {
+           required: true,
+           defaultValue: 0,
+           header: enable_sign_text,
+           renderer: Proxmox.Utils.format_boolean,
+           editor: {
+               xtype: 'pmgDKIMEnableEdit',
+               subject: enable_sign_text,
+           }
+       };
+
+       var selector_text = gettext('Selector');
+       me.rows.dkim_selector = {
+           required: true,
+           header: selector_text,
+           editor: {
+               xtype: 'proxmoxWindowEdit',
+               subject: selector_text,
+               isCreate: true,
+               method: 'POST',
+               url: '/config/dkim/selector',
+               items: [
+                   {
+                       xtype: 'displayfield',
+                       name: 'warning',
+                       userCls: 'pmx-hint',
+                       value: gettext('Warning: You need to update the _domainkey DNS records of all signed domains!'),
+                   },
+                   {
+                       xtype: 'proxmoxtextfield',
+                       fieldLabel: selector_text,
+                       name: 'selector',
+                       allowBlank: false,
+                       required: true,
+                       defaultValue: 'pmg'
+                   },
+                   {
+                       xtype: 'proxmoxKVComboBox',
+                       fieldLabel: gettext('Key Size'),
+                       name: 'keysize',
+                       value: '2048',
+                       allowBlank: false,
+                       deleteEmpty: false,
+                       required: true,
+                       comboItems: [
+                           ['1024', '1024'],
+                           ['2048', '2048'],
+                           ['4096', '4096'],
+                           ['8192', '8192']
+                       ]
+                   }
+               ]
+           }
+       };
+
+       me.add_boolean_row('dkim_sign_all_mail', gettext('Sign all Outgoing Mail'));
+
+       var baseurl = '/config/admin';
+
+       me.selModel = Ext.create('Ext.selection.RowModel', {});
+
+       Ext.apply(me, {
+           tbar: [{
+               text: gettext('View DNS Record'),
+               xtype: 'proxmoxButton',
+               disabled: true,
+               handler: function() {
+                   var win = Ext.create('PMG.SelectorViewer', {});
+                   win.load();
+                   win.show();
+               },
+               selModel: me.selModel,
+           },
+           {
+               text: gettext('Edit'),
+               xtype: 'proxmoxButton',
+               disabled: true,
+               handler: function() { me.run_editor(); },
+               selModel: me.selModel
+           }],
+           url: '/api2/json' + baseurl,
+           editorConfig: {
+               url: '/api2/extjs' + baseurl,
+               onlineHelp: 'pmgconfig_mailproxy_dkim'
+           },
+           interval: 5000,
+           cwidth1: 200,
+           listeners: {
+               itemdblclick: me.run_editor
+           }
+       });
+
+       me.callParent();
+
+       me.on('activate', me.rstore.startUpdate);
+       me.on('destroy', me.rstore.stopUpdate);
+       me.on('deactivate', me.rstore.stopUpdate);
+    }
+});
+
index b5f1bcc546bf0e1ca57157cc01eab31e76042345..55283c7d6075135f1444eb8960bb3e3d3be384cc 100644 (file)
@@ -44,6 +44,11 @@ Ext.define('PMG.MailProxyConfiguration', {
            title: gettext('TLS'),
            xtype: 'pmgMailProxyTLSPanel'
        },
+       {
+           itemId: 'dkim',
+           title: gettext('DKIM'),
+           xtype: 'pmgMailProxyDKIMPanel'
+       },
        {
            itemId: 'whitelist',
            title: gettext('Whitelist'),
diff --git a/js/MailProxyDKIMPanel.js b/js/MailProxyDKIMPanel.js
new file mode 100644 (file)
index 0000000..ebf9a4a
--- /dev/null
@@ -0,0 +1,44 @@
+Ext.define('PMG.DKIMDomains', {
+    extend: 'PMG.RelayDomains',
+    alias: ['widget.pmgDKIMDomains'],
+
+    baseurl: '/config/dkim/domains',
+    domain_desc: gettext('Sign Domain'),
+    onlineHelp: 'pmgconfig_mailproxy_dkim'
+});
+
+Ext.define('PMG.MailProxyDKIMPanel', {
+    extend: 'Ext.panel.Panel',
+    alias: 'widget.pmgMailProxyDKIMPanel',
+
+    layout: {
+       type: 'vbox',
+       align: 'stretch'
+    },
+
+    bodyPadding: '0 0 10 0',
+    defaults: {
+       collapsible: true,
+       animCollapse: false,
+       margin: '10 10 0 10'
+    },
+
+    initComponent: function() {
+       var me = this;
+
+       var DKIMSettings = Ext.create('PMG.DKIMSettings', {
+           title: gettext('Settings')
+       });
+
+       var DKIMDomains = Ext.create('PMG.DKIMDomains', {
+           title: gettext('Sign Domains')
+       });
+
+       me.items = [ DKIMSettings, DKIMDomains ];
+
+       me.callParent();
+
+       DKIMSettings.relayEvents(me, ['activate', 'deactivate', 'destroy']);
+       DKIMDomains.relayEvents(me, ['activate', 'deactivate', 'destroy']);
+    }
+});
index d377c32e11161159d359ffca2720484aef3b5a58..762b43ddc36e96755e40d05e04dfa602c4456a46 100644 (file)
@@ -46,6 +46,8 @@ JSSRC=                                                        \
        Transport.js                                    \
        MyNetworks.js                                   \
        RelayDomains.js                                 \
+       DKIMSettings.js                                 \
+       MailProxyDKIMPanel.js                           \
        MailProxyConfiguration.js                       \
        SpamDetectorLanguages.js                        \
        SpamDetectorOptions.js                          \
index 1f3bc65e8639fe39dc82aa9cdbf1c1143f5a59da..20fa45409324436253018ad2a2ed91c2f48eac23 100644 (file)
@@ -12,6 +12,7 @@
     <link rel="stylesheet" type="text/css" href="/pve2/ext6/crisp/resources/charts-all.css" />
     <link rel="stylesheet" type="text/css" href="/fontawesome/css/font-awesome.css" />
     <link rel="stylesheet" type="text/css" href="/pve2/css/ext6-pmg.css" />
+    <link rel="stylesheet" type="text/css" href="/pwt/css/ext6-pmx.css" />
     [% IF langfile %]
     <script type='text/javascript' src='/pve2/locale/pmg-lang-[% lang %].js'></script>
     [% ELSE %]