PluginProbe ʕ •ᴥ•ʔ
Limit Login Attempts Security – Login Security, 2FA, Firewall, Brute Force Prevention / 3.2.4
Limit Login Attempts Security – Login Security, 2FA, Firewall, Brute Force Prevention v3.2.4
3.2.4 3.2.3 3.2.2 3.2.1 3.2.0 trunk 2.0.0 2.1.0 2.10.0 2.10.1 2.11.0 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.14.0 2.15.0 2.15.1 2.15.2 2.16.0 2.17.0 2.17.1 2.17.2 2.17.3 2.17.4 2.18.0 2.19.0 2.19.1 2.19.2 2.2.0 2.20.0 2.20.1 2.20.2 2.20.3 2.20.4 2.20.5 2.20.6 2.21.0 2.21.1 2.22.0 2.22.1 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.25.0 2.25.1 2.25.10 2.25.11 2.25.12 2.25.13 2.25.14 2.25.15 2.25.16 2.25.17 2.25.18 2.25.19 2.25.2 2.25.20 2.25.21 2.25.22 2.25.23 2.25.24 2.25.25 2.25.26 2.25.27 2.25.28 2.25.29 2.25.3 2.25.4 2.25.5 2.25.6 2.25.7 2.25.8 2.25.9 2.26.0 2.26.1 2.26.10 2.26.11 2.26.12 2.26.13 2.26.14 2.26.15 2.26.16 2.26.17 2.26.18 2.26.19 2.26.2 2.26.20 2.26.21 2.26.22 2.26.23 2.26.24 2.26.25 2.26.26 2.26.27 2.26.28 2.26.3 2.26.4 2.26.5 2.26.6 2.26.7 2.26.8 2.26.9 2.3.0 2.4.0 2.5.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.8.0 2.8.1 2.9.0 3.0.0 3.0.1 3.0.2 3.1.0
limit-login-attempts-reloaded / core / mfa / MfaValidator.php
limit-login-attempts-reloaded / core / mfa Last commit date
rescuepayloadstorage 2 weeks ago MfaBackupCodes.php 2 weeks ago MfaBackupCodesInterface.php 2 weeks ago MfaEndpoint.php 2 weeks ago MfaEndpointInterface.php 2 weeks ago MfaManager.php 2 weeks ago MfaSettings.php 2 weeks ago MfaSettingsInterface.php 2 weeks ago MfaValidator.php 2 weeks ago RescueCode.php 2 weeks ago
MfaValidator.php
85 lines
1 <?php
2
3 namespace LLAR\Core\Mfa;
4
5 use LLAR\Core\MfaConstants;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 /**
12 * MFA validation: capability, block reason (availability), input validation.
13 * Single place for "can enable MFA" and rescue hash_id checks.
14 */
15 class MfaValidator {
16
17 /**
18 * Whether current user can manage MFA. Multisite: super_admin; else: manage_options.
19 *
20 * @return bool
21 */
22 public static function current_user_can_manage() {
23 if ( is_multisite() ) {
24 return is_super_admin();
25 }
26 return current_user_can( 'manage_options' );
27 }
28
29 /**
30 * Reason why MFA cannot be enabled, or null if it can.
31 * Requires OpenSSL (no base64 fallback — do not enable without proper encryption).
32 * SSL is not required but recommended; a warning is shown when MFA is used without HTTPS.
33 * Rescue endpoint rate limit uses global cooldown (no salt required).
34 *
35 * @return string|null One of MfaConstants::MFA_BLOCK_REASON_* or null
36 */
37 public static function get_block_reason() {
38 if ( ! MfaConstants::is_openssl_available() ) {
39 return MfaConstants::MFA_BLOCK_REASON_OPENSSL;
40 }
41 return null;
42 }
43
44 /**
45 * Human-readable message for a block reason.
46 *
47 * @param string $block_reason One of MfaConstants::MFA_BLOCK_REASON_*
48 * @return string
49 */
50 public static function get_block_message( $block_reason ) {
51 if ( MfaConstants::MFA_BLOCK_REASON_SSL === $block_reason ) {
52 return __( 'SSL/HTTPS is required for 2FA functionality. Please enable SSL on your site.', 'limit-login-attempts-reloaded' );
53 }
54 if ( MfaConstants::MFA_BLOCK_REASON_SALT === $block_reason ) {
55 return __( '2FA cannot be enabled: WordPress salt (AUTH_SALT or NONCE_SALT) or wp_salt() is required for secure rate limiting. Please define salts in wp-config.php.', 'limit-login-attempts-reloaded' );
56 }
57 if ( MfaConstants::MFA_BLOCK_REASON_OPENSSL === $block_reason ) {
58 return __( 'OpenSSL is required for secure rescue links. Enable the OpenSSL PHP extension. 2FA cannot be enabled without proper encryption.', 'limit-login-attempts-reloaded' );
59 }
60 return __( '2FA cannot be enabled.', 'limit-login-attempts-reloaded' );
61 }
62
63 /**
64 * Validate rescue token from URL.
65 * Supports new format (32 chars, base62) and legacy format (64 chars, hex).
66 *
67 * @param string $hash_id Raw token from query.
68 * @return string|false Sanitized token or false if invalid.
69 */
70 public static function validate_rescue_hash_id( $hash_id ) {
71 $hash_id = is_string( $hash_id ) ? sanitize_text_field( $hash_id ) : '';
72 $len = strlen( $hash_id );
73
74 if ( MfaConstants::RESCUE_TOKEN_LENGTH === $len && preg_match( '/^[A-Za-z0-9]{' . MfaConstants::RESCUE_TOKEN_LENGTH . '}$/', $hash_id ) ) {
75 return $hash_id;
76 }
77
78 if ( 64 === $len && preg_match( '/^[a-f0-9]{64}$/i', $hash_id ) ) {
79 return strtolower( $hash_id );
80 }
81
82 return false;
83 }
84 }
85