PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.3.1
Defender Security – Malware Scanner, Login Security & Firewall v5.3.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / model / setting / class-session-protection.php

class-session-protection.php in Defender Security – Malware Scanner, Login Security & Firewall 5.3.1, at src/model/setting/class-session-protection.php

116 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This file contains the class for the session protection settings.
4 *
5 * @package WP_Defender\Model\Setting
6 */
7
8 namespace WP_Defender\Model\Setting;
9
10 use Calotes\Model\Setting;
11 use WP_Defender\Traits\User;
12 use WP_Defender\Component\Security_Tweaks\Login_Duration;
13
14 /**
15 * This class handles the settings for session protection in WP Defender.
16 */
17 class Session_Protection extends Setting {
18 use User;
19
20 /**
21 * Feature status
22 *
23 * @defender_property
24 * @var bool
25 */
26 public $enabled = false;
27
28 /**
29 * Idle Session Timeout.
30 *
31 * Set the idle timeout period (in hours) after which inactive sessions will be automatically logged out.
32 *
33 * @defender_property
34 * @var int
35 */
36 public $idle_timeout = 1;
37
38 /**
39 * User Session Lock.
40 *
41 * Lock and automatically end user sessions if any selected properties change.
42 *
43 * @defender_property
44 * @var array
45 */
46 public $lock_properties = array();
47
48 /**
49 * Login duration.
50 *
51 * Set a login duration override for all user sessions. Once the duration expires, users will be logged out automatically.
52 * The process related to Login Duration will be added in the next releases.
53 *
54 * @defender_property
55 * @var int
56 */
57 public $login_duration = Login_Duration::DEFAULT_DAYS;
58
59 /**
60 * Select the user roles to apply above session protection to.
61 *
62 * @defender_property
63 * @var array
64 */
65 public $user_roles = array();
66
67 /**
68 * Option name.
69 *
70 * @var string
71 */
72 protected $table = 'wd_session_protection_settings';
73
74 /**
75 * Initializes the object before loading.
76 *
77 * @return void
78 */
79 protected function before_load(): void {
80 $tweak_duration = wd_di()->get( Login_Duration::class )->get_tweak_duration();
81 $this->login_duration = ! empty( $tweak_duration )
82 ? $tweak_duration
83 : $this->login_duration;
84 $this->user_roles = array( 'administrator' );
85 }
86
87 /**
88 * Has lock properties?
89 *
90 * @return bool
91 */
92 public function has_properties(): bool {
93 return ! empty( $this->lock_properties );
94 }
95
96 /**
97 * Is property locked?
98 *
99 * @param string $property The property to check.
100 *
101 * @return bool
102 */
103 public function is_property_locked( $property ): bool {
104 return in_array( $property, $this->lock_properties, true );
105 }
106
107 /**
108 * Return the module slug.
109 *
110 * @return string
111 */
112 public static function get_module_slug(): string {
113 return 'session-protection';
114 }
115 }
116