PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / trunk
JetBackup – Backup, Restore & Migrate vtrunk
3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / src / JetBackup / Settings / Security.php
backup / src / JetBackup / Settings Last commit date
.htaccess 1 year ago Automation.php 10 months ago General.php 3 months ago Integrations.php 4 months ago Logging.php 4 months ago Maintenance.php 4 months ago Notifications.php 4 months ago Performance.php 3 months ago Restore.php 1 year ago Security.php 23 hours ago Settings.php 4 months ago Updates.php 4 months ago index.html 1 year ago web.config 1 year ago
Security.php
105 lines
1 <?php
2
3 namespace JetBackup\Settings;
4
5 use JetBackup\Config\Config;
6 use JetBackup\Config\System;
7 use JetBackup\Exception\AjaxException;
8 use JetBackup\Exception\FieldsValidationException;
9 use JetBackup\Exception\IOException;
10 use JetBackup\Factory;
11 use JetBackup\MFA\GoogleAuthenticator;
12 use JetBackup\Wordpress\UI;
13 use ReflectionException;
14
15 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
16
17 class Security extends Settings {
18
19 const SECTION = 'security';
20
21 const MFA_ENABLED = 'MFA_ENABLED';
22 const MFA_ALLOW_CLI = 'MFA_ALLOW_CLI';
23 const ABILITIES_ENABLED = 'ABILITIES_ENABLED';
24 const MFA_ALLOW_ABILITIES = 'MFA_ALLOW_ABILITIES';
25 const DAILY_CHECKSUM_CHECK = 'DAILY_CHECKSUM_CHECK';
26 const DATADIR_SECURED = 'SECURITY_DATADIR_SECURED';
27 const DATADIR_RECOMMENDED = 'SECURITY_DATADIR_RECOMMENDED';
28
29 /**
30 * @throws IOException
31 * @throws ReflectionException
32 */
33 public function __construct() {
34 parent::__construct(self::SECTION);
35 }
36
37 /**
38 * @return bool
39 */
40 public function isMFAEnabled():bool { return (bool) $this->get(self::MFA_ENABLED, false); }
41 public function isMFAAllowCLI():bool { return (bool) $this->get(self::MFA_ALLOW_CLI, false); }
42 public function isAbilitiesEnabled():bool { return (bool) $this->get(self::ABILITIES_ENABLED, false); }
43 public function isMFAAllowAbilities():bool { return (bool) $this->get(self::MFA_ALLOW_ABILITIES, false); }
44
45 /**
46 * @param bool $value
47 *
48 * @return void
49 */
50 public function setMFAEnabled(bool $value):void { $this->set(self::MFA_ENABLED,$value); }
51 public function setMFAAllowCLI(bool $value):void { $this->set(self::MFA_ALLOW_CLI,$value); }
52 public function setAbilitiesEnabled(bool $value):void { $this->set(self::ABILITIES_ENABLED,$value); }
53 public function setMFAAllowAbilities(bool $value):void { $this->set(self::MFA_ALLOW_ABILITIES,$value); }
54
55 /**
56 * @return bool
57 */
58 public function isValidateChecksumsEnabled():bool { return (bool) $this->get(self::DAILY_CHECKSUM_CHECK, false); }
59
60 /**
61 * @param bool $value
62 *
63 * @return void
64 */
65 public function setValidateChecksumsEnabled(bool $value):void { $this->set(self::DAILY_CHECKSUM_CHECK, $value); }
66
67 /**
68 * @return array
69 */
70 public function getDisplay():array {
71 return [
72 self::DATADIR_SECURED => System::isDataDirSecured() ? 1 : 0,
73 self::DATADIR_RECOMMENDED => System::getRecommendSecurePath(),
74 self::MFA_ENABLED => $this->isMFAEnabled() ? 1 : 0,
75 self::MFA_ALLOW_CLI => $this->isMFAAllowCLI() ? 1 : 0,
76 self::ABILITIES_ENABLED => $this->isAbilitiesEnabled() ? 1 : 0,
77 self::MFA_ALLOW_ABILITIES => $this->isMFAAllowAbilities() ? 1 : 0,
78 Config::ALTERNATE_DATA_FOLDER => Factory::getConfig()->getAlternateDataFolder(),
79 self::DAILY_CHECKSUM_CHECK => $this->isValidateChecksumsEnabled() ? 1 : 0,
80 ];
81 }
82
83 /**
84 * @return array
85 */
86 public function getDisplayCLI():array {
87 return [
88 'MFA Enabled' => $this->isMFAEnabled() ? "Yes" : "No",
89 'MFA Allow CLI' => $this->isMFAAllowCLI() ? "Yes" : "No",
90 'Abilities API Enabled' => $this->isAbilitiesEnabled() ? "Yes" : "No",
91 'MFA Allow Abilities API' => $this->isMFAAllowAbilities() ? "Yes" : "No",
92 'Alternate Data Directory' => Factory::getConfig()->getAlternateDataFolder(),
93 'Validate System Files Checksums' => $this->isValidateChecksumsEnabled() ? "Yes" : "No",
94 ];
95 }
96
97 /**
98 */
99 public function validateFields():void {}
100
101 public function save(): void {
102 if (!$this->isMFAEnabled()) GoogleAuthenticator::clearCookie();
103 parent::save();
104 }
105 }