Просмотр исходного кода

Ticket #5529 - Protect confidential information. SMTP Mailer.

AntonLV 2 месяцев назад
Родитель
Сommit
b82d85e09d

+ 1 - 1
install/sql/system.sql

@@ -329,7 +329,7 @@ CREATE TABLE `sys_options` (
   `caption` varchar(255) NOT NULL default '',
   `info` varchar(255) NOT NULL default '',
   `value` mediumtext NOT NULL,
-  `type` enum('value','digit','secret','text','code','checkbox','select','combobox','file','image','list','rlist','rgb','rgba','datetime') NOT NULL default 'digit',
+  `type` enum('value','digit','secret','secret_text','text','code','checkbox','select','combobox','file','image','list','rlist','rgb','rgba','datetime') NOT NULL default 'digit',
   `extra` text NOT NULL default '',
   `check` varchar(32) NOT NULL,
   `check_params` text NOT NULL,

+ 2 - 2
modules/boonex/smtpmailer/install/sql/enable.sql

@@ -26,7 +26,7 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_smtp_test_subj', '[TEST] ', @iCategId, '_bx_smtp_option_test_subj', 'digit', '', '', 104, '');
 
 INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order` )  
-VALUES (@iTypeId, 'bx_smtp_oauth', '_bx_smtp_adm_stg_cpt_category_oauth', 1);
+VALUES (@iTypeId, 'bx_smtp_oauth', '_bx_smtp_adm_stg_cpt_category_oauth', 2);
 SET @iCategId = LAST_INSERT_ID();
 
 INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_error`, `order`, `extra`) VALUES
@@ -35,7 +35,7 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_smtp_oauth_tenant_id', '', @iCategId, '_bx_smtp_oauth_tenant_id', 'digit', '', '', 30, ''),
 ('bx_smtp_oauth_tenant_name', '', @iCategId, '_bx_smtp_oauth_tenant_name', 'digit', '', '', 40, ''),
 ('bx_smtp_oauth_cert_public', '', @iCategId, '_bx_smtp_oauth_cert_public', 'text', '', '', 50, ''),
-('bx_smtp_oauth_cert_private', '', @iCategId, '_bx_smtp_oauth_cert_private', 'text', '', '', 60, '');
+('bx_smtp_oauth_cert_private', '', @iCategId, '_bx_smtp_oauth_cert_private', 'secret_text', '', '', 60, '');
 
 
 -- logs

+ 1 - 0
studio/classes/BxDolStudioOptions.php

@@ -480,6 +480,7 @@ class BxDolStudioOptions extends BxDol
 
         switch($aOption['type']) {
             case 'secret':
+            case 'secret_text':
                 if(strcmp(bx_gen_secret($aOption['value']), $mixedValue) == 0)
                     $mixedValue = $aOption['value'];
                 break;

+ 0 - 10
studio/template/scripts/BxBaseStudioFormView.php

@@ -184,16 +184,6 @@ class BxBaseStudioFormView extends BxDolStudioForm
 
         return parent::genInputCheckboxSet($aInput);
     }
-
-    protected function _genInputStandardAttrs(&$aInput)
-    {
-        $aAttrs = parent::_genInputStandardAttrs($aInput);
-
-        if($aInput['type'] == 'text' && ($aInput['secret'] ?? false) && ($sValue = $aAttrs['value'] ?? false))
-            $aAttrs['value'] = bx_gen_secret($sValue);
-
-        return $aAttrs;
-    }
 }
 
 /** @} */

+ 5 - 11
studio/template/scripts/BxBaseStudioOptions.php

@@ -630,16 +630,6 @@ class BxBaseStudioOptions extends BxDolStudioOptions
                 ];
                 break;
             case 'digit':
-                $aField = [
-                    'type' => 'text',
-                    'name' => $aItem['name'],
-                    'caption' => _t($aItem['caption']),
-                    'info' => _t($aItem['info']),
-                    'value' => $mixedValue,
-                    'attrs' => $aAttributes,
-                    'db' => ['pass' => 'Xss'],
-                ];
-                break;
             case 'secret':
                 $aField = [
                     'type' => 'text',
@@ -648,11 +638,13 @@ class BxBaseStudioOptions extends BxDolStudioOptions
                     'info' => _t($aItem['info']),
                     'value' => $mixedValue,
                     'attrs' => $aAttributes,
-                    'secret' => 1,
                     'db' => ['pass' => 'Xss'],
                 ];
+                if($aItem['type'] == 'secret')
+                    $aField['secret'] = 1;
                 break;
             case 'text':
+            case 'secret_text':
                 $aField = [
                     'type' => 'textarea',
                     'name' => $aItem['name'],
@@ -662,6 +654,8 @@ class BxBaseStudioOptions extends BxDolStudioOptions
                     'attrs' => $aAttributes,
                     'db' => ['pass' => 'XssHtml'],
                 ];
+                if($aItem['type'] == 'secret_text')
+                    $aField['secret'] = 1;
                 break;
             case 'code':
                 $aField = [

+ 6 - 0
template/scripts/BxBaseFormView.php

@@ -1572,7 +1572,11 @@ BLAH;
         }
 
         if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
+
         if (isset($aInput['value'])) $aAttrs['value'] = $aInput['value'];
+        if ($aInput['type'] == 'text' && ($aInput['secret'] ?? false) && ($sValue = $aAttrs['value'] ?? false))
+            $aAttrs['value'] = bx_gen_secret($sValue);
+
         if (isset($aInput['db']['pass']) && ('DateUtc' == $aInput['db']['pass'] || 'DateTimeUtc' == $aInput['db']['pass'])) $aAttrs['data-utc'] = 1;
 
         if (!isset($aAttrs['data-format-24h']))
@@ -1716,6 +1720,8 @@ BLAH;
 
         $bTagsAllowed = $bHtml || $bCode || ($aInput['html_tags'] ?? false);
         $sValue = isset($aInput['value']) ? bx_process_output($bTagsAllowed ? $aInput['value'] : strip_tags($aInput['value']), BX_DATA_TEXT, ['no_process_macros']) : '';
+        if(($aInput['secret'] ?? false) && $sValue)
+            $sValue = bx_gen_secret($sValue);
 
         $aAgent = [];
         if(!empty($this->_aAgentsFormObject)) {