Changeset 3261174
- Timestamp:
- 03/25/2025 03:11:08 AM (12 months ago)
- Location:
- qe-fid-id
- Files:
-
- 67 added
- 8 deleted
- 10 edited
-
tags/1.1.1 (deleted)
-
tags/1.2.0 (deleted)
-
tags/1.2.1 (deleted)
-
tags/1.2.2 (deleted)
-
tags/1.2.3 (deleted)
-
tags/1.2.4 (deleted)
-
tags/1.2.5 (deleted)
-
tags/1.2.6 (deleted)
-
tags/1.2.9 (added)
-
tags/1.2.9/LICENSE (added)
-
tags/1.2.9/assets (added)
-
tags/1.2.9/assets/css (added)
-
tags/1.2.9/assets/css/admin.css (added)
-
tags/1.2.9/assets/css/modal.css (added)
-
tags/1.2.9/assets/images (added)
-
tags/1.2.9/assets/images/fid-logo-full.svg (added)
-
tags/1.2.9/assets/images/fid.png (added)
-
tags/1.2.9/assets/images/icon.png (added)
-
tags/1.2.9/assets/js (added)
-
tags/1.2.9/assets/js/admin.js (added)
-
tags/1.2.9/assets/js/admin.js.LICENSE.txt (added)
-
tags/1.2.9/assets/js/gate.js (added)
-
tags/1.2.9/assets/js/gate.js.LICENSE.txt (added)
-
tags/1.2.9/autoload.php (added)
-
tags/1.2.9/includes (added)
-
tags/1.2.9/includes/Admin.php (added)
-
tags/1.2.9/includes/Constants (added)
-
tags/1.2.9/includes/Constants/AccessStatus.php (added)
-
tags/1.2.9/includes/Constants/Options.php (added)
-
tags/1.2.9/includes/Constants/PipeStatus.php (added)
-
tags/1.2.9/includes/Endpoint (added)
-
tags/1.2.9/includes/Endpoint/Admin.php (added)
-
tags/1.2.9/includes/Endpoint/Gate.php (added)
-
tags/1.2.9/includes/Endpoint/PluginAdmin.php (added)
-
tags/1.2.9/includes/Endpoint/wp-load.php (added)
-
tags/1.2.9/includes/EventPipes (added)
-
tags/1.2.9/includes/EventPipes/DeletePipe.php (added)
-
tags/1.2.9/includes/EventPipes/LoginPipe.php (added)
-
tags/1.2.9/includes/EventPipes/Pipe.php (added)
-
tags/1.2.9/includes/EventPipes/PipeEvent.php (added)
-
tags/1.2.9/includes/EventPipes/PipeEventReturn.php (added)
-
tags/1.2.9/includes/EventPipes/RegisterPipe.php (added)
-
tags/1.2.9/includes/EventPipes/UpdatePipe.php (added)
-
tags/1.2.9/includes/FiDAuthApi.php (added)
-
tags/1.2.9/includes/Login.php (added)
-
tags/1.2.9/includes/Models (added)
-
tags/1.2.9/includes/Models/DeleteRequest.php (added)
-
tags/1.2.9/includes/Models/DeleteResponse.php (added)
-
tags/1.2.9/includes/Models/EligibleUser.php (added)
-
tags/1.2.9/includes/Models/EnrollRequest.php (added)
-
tags/1.2.9/includes/Models/EnrollResponse.php (added)
-
tags/1.2.9/includes/Models/GenericResponse.php (added)
-
tags/1.2.9/includes/Models/RestConfig.php (added)
-
tags/1.2.9/includes/Models/Tokens.php (added)
-
tags/1.2.9/includes/Models/UpdateRequest.php (added)
-
tags/1.2.9/includes/Models/VerifyRequest.php (added)
-
tags/1.2.9/includes/Models/VerifyResponse.php (added)
-
tags/1.2.9/includes/Modules (added)
-
tags/1.2.9/includes/Modules/LoginMonitor.php (added)
-
tags/1.2.9/includes/Plugin.php (added)
-
tags/1.2.9/includes/PluginMeta.php (added)
-
tags/1.2.9/includes/Users (added)
-
tags/1.2.9/includes/Users/FidUser.php (added)
-
tags/1.2.9/includes/Users/UserRoster.php (added)
-
tags/1.2.9/includes/Utils (added)
-
tags/1.2.9/includes/Utils/Helpers.php (added)
-
tags/1.2.9/includes/Utils/Networking.php (added)
-
tags/1.2.9/includes/Utils/Validators.php (added)
-
tags/1.2.9/index.php (added)
-
tags/1.2.9/qe-fid-plugin.php (added)
-
tags/1.2.9/readme.txt (added)
-
tags/1.2.9/uninstall.php (added)
-
trunk/autoload.php (modified) (1 diff)
-
trunk/includes/Constants/Options.php (modified) (1 diff)
-
trunk/includes/Endpoint/Admin.php (modified) (10 diffs)
-
trunk/includes/Endpoint/PluginAdmin.php (modified) (8 diffs)
-
trunk/includes/Login.php (modified) (4 diffs)
-
trunk/includes/Models/Tokens.php (added)
-
trunk/includes/Modules (added)
-
trunk/includes/Modules/LoginMonitor.php (added)
-
trunk/includes/Plugin.php (modified) (12 diffs)
-
trunk/includes/Utils/Networking.php (modified) (5 diffs)
-
trunk/qe-fid-plugin.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/uninstall.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
qe-fid-id/trunk/autoload.php
r2848772 r3261174 3 3 namespace QeFid\ID; 4 4 5 define('QE_FID_VERSION', '1. 1.0');5 define('QE_FID_VERSION', '1.2.9'); 6 6 7 7 /** -
qe-fid-id/trunk/includes/Constants/Options.php
r3042256 r3261174 59 59 static string $API_KEY_ACCESS = "qe_fid_access_key"; 60 60 static string $API_KEY_REFRESH = "qe_fid_refresh_key"; 61 static string $API_LICENCE_KEY_ACCESS_REFRESH_PAIR = "qe_fid_access_refresh_key_pair"; 62 static string $LICENCE_EXPIRATION_TIME = "qe_fid_license_expiration_time"; 61 63 62 64 -
qe-fid-id/trunk/includes/Endpoint/Admin.php
r3140374 r3261174 16 16 use QeFid\ID; 17 17 use QeFid\ID\Constants\Options; 18 use QeFid\ID\Models\Tokens; 18 19 use QeFid\ID\Plugin; 19 20 use QeFid\ID\PluginMeta; … … 351 352 $endpoint_option = get_option(Options::$LICENSING_API_ENDPOINT); 352 353 $license_key = get_option(Options::$FID_LICENSE_KEY); 353 $access = get_option(Options::$API_KEY_ACCESS); 354 $refresh = get_option(Options::$API_KEY_REFRESH); 354 $tokens = Tokens::get_instance(); 355 355 $contact_email_option = get_option(Options::$FID_ADMIN_EMAIL); 356 $expiration_time = get_option(Options::$LICENCE_EXPIRATION_TIME); 356 357 357 358 return new \WP_REST_Response(array( 358 359 'success' => true, 359 'email' => !$contact_email_option ? '' : $contact_email_option, 360 'endpoint_url' => !$endpoint_option ? '' : $endpoint_option, 361 'license_key' => !$license_key ? '' : $license_key, 362 'access_key' => !$access ? '' : '********', 363 'refresh_key' => !$refresh ? '' : '********' 360 'email' => $contact_email_option ?: '', 361 'endpoint_url' => $endpoint_option ?: '', 362 'license_key' => $license_key ?: '', 363 'access_key' => !$tokens || !$tokens->tokensValid() ? '' : '********', 364 'refresh_key' => !$tokens || !$tokens->tokensValid() ? '' : '********', 365 'expiration' => $expiration_time ?: '', 364 366 ), 200); 365 367 } … … 376 378 $endpoint_option = update_option(Options::$LICENSING_API_ENDPOINT, $request->get_param('endpoint_url')); 377 379 $license_key = update_option(Options::$FID_LICENSE_KEY, $request->get_param('license_key')); 380 $expiration_time = get_option(Options::$LICENCE_EXPIRATION_TIME); 378 381 379 382 $ok = $updated || $endpoint_option || $license_key; … … 383 386 'endpoint_url' => $request->get_param('endpoint_url'), 384 387 'license_key' => $request->get_param('license_key'), 388 'expiration' => $expiration_time ?: '', 385 389 ), 200); 386 390 } … … 395 399 { 396 400 $deleted = false; 397 $access_key = get_option(Options::$API_KEY_ACCESS); 398 $refresh_key = get_option(Options::$API_KEY_REFRESH); 399 if (!$access_key && !$refresh_key) { 401 $tokens = Tokens::get_instance(); 402 if (!$tokens || !$tokens->tokensValid()) { 400 403 $lk = delete_option(Options::$FID_LICENSE_KEY); 401 404 $endpoint_option = delete_option(Options::$LICENSING_API_ENDPOINT); 405 $deleted = delete_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR); 402 406 $deleted = delete_option(Options::$FID_API_ENDPOINT); 403 407 $deleted = delete_option(Options::$FID_ADMIN_EMAIL); … … 423 427 if ($activated['success'] === true) { 424 428 ID\Login::get_instance()->activate_login_form(); 425 $access = get_option(Options::$API_KEY_ACCESS); 426 $refresh = get_option(Options::$API_KEY_REFRESH); 429 $tokens = Tokens::get_instance(); 427 430 return new \WP_REST_Response(array( 428 431 'success' => true, 429 432 'license_key' => $request->get_param('license_key'), 430 'access_key' => !$ access? '' : '********',431 'refresh_key' => !$ refresh? '' : '********',433 'access_key' => !$tokens || !$tokens->tokensValid() ? '' : '********', 434 'refresh_key' => !$tokens || !$tokens->tokensValid() ? '' : '********', 432 435 'error' => '', 433 436 ), 200); … … 441 444 ); 442 445 } 443 $access = get_option(Options::$API_KEY_ACCESS); 444 $refresh = get_option(Options::$API_KEY_REFRESH); 446 $tokens = Tokens::get_instance(); 445 447 return new \WP_REST_Response(array( 446 448 'success' => false, 447 449 'license_key' => $request->get_param('license_key'), 448 'access_key' => !$ access? '' : '********',449 'refresh_key' => !$ refresh? '' : '********',450 'access_key' => !$tokens || !$tokens->tokensValid() ? '' : '********', 451 'refresh_key' => !$tokens || !$tokens->tokensValid() ? '' : '********', 450 452 'error' => $activated['error'], 451 453 ), 200); … … 460 462 public function deactivate_fid_license($request) 461 463 { 462 $refresh_key = get_option(Options::$API_KEY_REFRESH);464 $refresh_key = Tokens::get_instance()->get_refresh_token(); 463 465 $deactivated = ID\Endpoint\PluginAdmin::deactivate_license($refresh_key); 464 466 if ($deactivated['success'] === true) { 465 $deleted_access = delete_option(Options::$API_KEY_ACCESS); 466 $deleted_refresh = delete_option(Options::$API_KEY_REFRESH); 467 $deleted_keys = delete_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR); 467 468 $deleted_endpoint = delete_option(Options::$FID_API_ENDPOINT); 468 469 $deleted_endpoint = delete_option(Options::$FID_LICENSE_USER_LIMIT); 469 470 470 $ok = $deleted_ access && $deleted_refresh&& $deleted_endpoint;471 $ok = $deleted_keys && $deleted_endpoint; 471 472 472 473 return new \WP_REST_Response(array( … … 479 480 } 480 481 482 $tokens = Tokens::get_instance(); 481 483 return new \WP_REST_Response(array( 482 484 'success' => false, 483 485 'license_key' => get_option(Options::$FID_LICENSE_KEY), 484 'access_key' => ! get_option(Options::$API_KEY_ACCESS) ? '' : '********',485 'refresh_key' => ! get_option(Options::$API_KEY_REFRESH) ? '' : '********',486 'access_key' => !$tokens || !$tokens->tokensValid() ? '' : '********', 487 'refresh_key' => !$tokens || !$tokens->tokensValid() ? '' : '********', 486 488 'error' => $deactivated['error'], 487 489 ), 200); … … 639 641 } 640 642 $renewed = ID\Endpoint\PluginAdmin::renew_license(); 643 $tokens = Tokens::get_instance(); 641 644 return new \WP_REST_Response(array( 642 645 'success' => true, 643 'license_key' => get_option(Options::$FID_LICENSE_KEY),644 'access_key' => get_option(Options::$API_KEY_ACCESS),645 'refresh_key' => get_option(Options::$API_KEY_REFRESH),646 'license_key' => get_option(Options::$FID_LICENSE_KEY), 647 'access_key' => !$tokens || !$tokens->tokensValid() ? false : '********', 648 'refresh_key' => !$tokens || !$tokens->tokensValid() ? false : '********', 646 649 'error' => $renewed['error'], 647 650 ), 200); -
qe-fid-id/trunk/includes/Endpoint/PluginAdmin.php
r3140374 r3261174 16 16 use QeFid\ID; 17 17 use QeFid\ID\Constants\Options; 18 use QeFid\ID\Models\Tokens; 19 use QeFid\ID\Modules\LoginMonitor; 20 use QeFid\ID\Plugin; 18 21 19 22 /** … … 23 26 class PluginAdmin 24 27 { 28 const ONE_DAY = 8640; 29 const TWO_AND_HALF_DAYS = 216000; 30 25 31 protected static function get_owner_site_url(): string 26 32 { 27 33 return get_site_url(); 34 } 35 36 public static function get_instance() 37 { 38 return new self(); 39 } 40 41 public static function get_plugin_slug() 42 { 43 return "qe-fid-id-plugin"; 44 } 45 46 public static function get_cron_hook() 47 { 48 return static::get_plugin_slug() . '_license_renew_hook'; 28 49 } 29 50 … … 51 72 { 52 73 return PluginAdmin::get_licensing_url() . "/" . "renew-license"; 74 } 75 76 /** 77 * Decode a jwt token and read the expiration date claim called 'exp' which is a unix timestamp 78 * The date is compared with the current unix timestamp 79 * if the unix timestamp is within 15 minutes or less or is greater than the exp date 80 * It should call the renew licence method below 81 */ 82 public static function check_token_expiry($skip = false) 83 { 84 $tokens = Tokens::get_instance(); 85 if ($tokens == false || !$tokens->tokensValid()) { 86 static::remove_token_expiry_check(); 87 return; 88 } 89 90 $token = explode(".", $tokens->get_access_token()); 91 $token = json_decode(base64_decode($token[1]), true); 92 $exp = isset($token["exp"]) ? $token['exp'] : 0; //will automatically fail all checks if license is tampered with 93 $duration = isset($token['duration']) ? $token['duration'] : 'NA'; 94 $current = time(); 95 if ($exp - $current <= 0) { 96 $result = static::renew_license(); 97 if (isset($result['error']) && $result['success'] === false) { 98 (new LoginMonitor)->log_login_attempt("Renewing License", 0); 99 delete_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR); 100 delete_option(Options::$LICENCE_EXPIRATION_TIME); 101 Plugin::deactivate(); 102 } 103 return; 104 } 105 106 // If a license is not renewed via payment, the license on the server is automatically invalidated 107 // This is an attempt to keep the service from deactivating or locking if an invalidated license is not renewed in time 108 if (!$skip && ($exp - $current <= self::TWO_AND_HALF_DAYS)) { 109 $result = static::renew_license(); 110 if (isset($result['success']) && $result['success'] === true) { 111 (new LoginMonitor)->log_custom_message("Renewed License", "$duration"); 112 113 return static::check_token_expiry(true); 114 } 115 } 116 117 add_option(Options::$LICENCE_EXPIRATION_TIME, ($exp - $current)); 118 } 119 120 /** 121 * Add a hook that fires when the plugins load to check the token expiry 122 */ 123 public function add_token_expiry_check() 124 { 125 // add_action(static::get_cron_hook(), [$this, 'check_token_expiry']); 126 127 if (! wp_next_scheduled(static::get_cron_hook())) { 128 wp_schedule_event(time(), 'daily', static::get_cron_hook()); 129 } 130 // add_action('plugins_loaded', [$this, 'check_token_expiry']); 131 } 132 133 /** 134 * remove the hook that checks the token expiry 135 */ 136 public function remove_token_expiry_check() 137 { 138 $timestamp = wp_next_scheduled(static::get_cron_hook()); 139 if ($timestamp == false) { 140 return; 141 } 142 wp_unschedule_event($timestamp, static::get_cron_hook()); 53 143 } 54 144 … … 88 178 89 179 $return['success'] = PluginAdmin::save_auth_tokens($response); 180 static::get_instance()->add_token_expiry_check(); 90 181 $plugin->activate(); 91 182 return $return; … … 104 195 ); 105 196 106 $token = get_option(Options::$API_KEY_REFRESH); 107 if ($token == false) { 197 $tokens = Tokens::get_instance(); 198 $token = $tokens->get_refresh_token(); 199 if (!$tokens || !$tokens->tokensValid() || !$token) { 108 200 $return['error'] = "No Active License"; 109 201 $return['success'] = false; … … 159 251 return $return; 160 252 } 161 162 253 static::get_instance()->remove_token_expiry_check(); 163 254 164 255 return $return; … … 196 287 if ( 197 288 !isset($tknArray["tokens"]) || 198 $tknArray["tokens"]["access_token"] == ""||199 $tknArray["tokens"]["refresh_token"] == ""289 empty($tknArray["tokens"]["access_token"]) || 290 empty($tknArray["tokens"]["refresh_token"]) 200 291 ) { 201 292 return false; 202 293 } 203 update_option(Options::$API_KEY_ACCESS, $tknArray["tokens"]["access_token"]); 204 update_option(Options::$API_KEY_REFRESH, $tknArray["tokens"]["refresh_token"]);294 295 Tokens::setTokens($tknArray["tokens"]["access_token"], $tknArray["tokens"]["refresh_token"]); 205 296 206 297 //extract base 64 encoded data from the token … … 214 305 } 215 306 } 307 add_action(PluginAdmin::get_cron_hook(), ['QeFid\\ID\\Endpoint\\PluginAdmin', 'check_token_expiry']); 308 if (! wp_next_scheduled(PluginAdmin::get_cron_hook())) { 309 wp_schedule_event(time(), 'daily', PluginAdmin::get_cron_hook()); 310 } -
qe-fid-id/trunk/includes/Login.php
r3000397 r3261174 16 16 use QeFid\ID\Constants\Options; 17 17 use QeFid\ID\Models\RestConfig; 18 use QeFid\ID\Models\Tokens; 18 19 19 20 /** … … 94 95 $enrolled = get_option(Options::$FID_USER_MAPPING_ROSTER); 95 96 $active_license = get_option(Options::$FID_LICENSE_KEY); 96 $activated_service = get_option(Options::$API_KEY_ACCESS); 97 $activated_service_key = get_option(Options::$API_KEY_REFRESH); 97 $activated_service_keys = Tokens::get_instance(); 98 98 $api_valid = get_option(Options::$FID_API_ENDPOINT); 99 99 $activated_guard = get_option(Options::$FID_PLUGIN_LOGIN_GUARD_STATE); 100 $valid_plugin_config = $active_license && $activated_service && $activated_service_key&& $api_valid;100 $valid_plugin_config = $active_license && $activated_service_keys && $activated_service_keys->tokensValid() && $api_valid; 101 101 if ( 102 102 !$enrolled || … … 127 127 $enrolled = get_option(Options::$FID_USER_MAPPING_ROSTER); 128 128 $active_license = get_option(Options::$FID_LICENSE_KEY); 129 $activated_service = get_option(Options::$API_KEY_ACCESS); 130 $activated_service_key = get_option(Options::$API_KEY_REFRESH); 129 $activated_service_keys = Tokens::get_instance(); 131 130 $api_valid = get_option(Options::$FID_API_ENDPOINT); 132 $valid_plugin_config = $active_license && $activated_service && $activated_service_key&& $api_valid;131 $valid_plugin_config = $active_license && $activated_service_keys && $activated_service_keys->tokensValid() && $api_valid; 133 132 if ( 134 133 !$enrolled || … … 151 150 } 152 151 153 public function deactivate_login_form() 154 { 155 } 152 public function deactivate_login_form() {} 156 153 157 154 // add_filter('wp_authenticate_user','wdm_validate_login_captcha',10,2); -
qe-fid-id/trunk/includes/Plugin.php
r3140374 r3261174 15 15 16 16 use QeFid\ID\Constants\Options; 17 use QeFid\ID\Endpoint\PluginAdmin; 17 18 use QeFid\ID\EventPipes\DeletePipe; 18 19 use QeFid\ID\EventPipes\LoginPipe; … … 25 26 use QeFid\ID\Models\EnrollRequest; 26 27 use QeFid\ID\Models\EnrollResponse; 28 use QeFid\ID\Models\Tokens; 27 29 use QeFid\ID\Models\UpdateRequest; 28 30 use QeFid\ID\Models\VerifyRequest; 29 31 use QeFid\ID\Models\VerifyResponse; 32 use QeFid\ID\Modules\LoginMonitor; 30 33 use QeFid\ID\Users\FidUser; 31 34 use QeFid\ID\Users\UserRoster; … … 189 192 } 190 193 194 191 195 self::get_instance()->set_plugin_nonce(get_option(Options::$FID_PLUGIN_NONCE)); 192 193 196 $roster = self::get_user_roster(); 194 197 if ( … … 206 209 // Ensure the user has an activated license to be able to make api calls before locking the user credentials 207 210 $active_license = get_option(Options::$FID_LICENSE_KEY); 208 $access_token = get_option(Options::$API_KEY_ACCESS); 209 $refresh_token = get_option(Options::$API_KEY_REFRESH); 210 if (!$active_license || !$access_token || !$refresh_token) { 211 $token_pair = Tokens::get_instance(); 212 if (!$active_license || !$token_pair || !$token_pair->tokensValid()) { 211 213 return; 212 214 } … … 269 271 $roster = self::get_user_roster(); 270 272 273 $checks = PluginAdmin::get_instance()->remove_token_expiry_check(); 271 274 if (UserRoster::$ROSTER_STATUS_INACTIVE === $roster->roster_status) { 272 275 return; … … 323 326 } 324 327 328 if (count(self::$modules) == 0) { 329 try { 330 $module = LoginMonitor::get_instance(); 331 self::$modules = [$module]; 332 } catch (\Exception $e) { 333 print_r(json_encode($e)); 334 } 335 } 336 337 PluginAdmin::get_instance()->add_token_expiry_check(); 338 325 339 return self::$instance; 326 340 } 341 342 static $modules = []; 327 343 328 344 /** … … 579 595 } 580 596 581 if (!get_option(Options::$API_ KEY_ACCESS)) {597 if (!get_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR)) { 582 598 return new PipeEventReturn("", array( 583 599 "error" => "Invalid API key, please ensure you have activated the license from the FiD Auth settings page", … … 697 713 return new PipeEventReturn("", "Invalid endpoint file object or pin"); 698 714 } 699 if (!get_option(Options::$API_ KEY_ACCESS)) {715 if (!get_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR)) { 700 716 return new PipeEventReturn("", array( 701 717 "error" => "Unauthorized access", … … 717 733 if (isset($parsed_response["error"]) && $parsed_response["error"] != "") { 718 734 Plugin::process_api_errors($parsed_response["error"]); 735 LoginMonitor::get_instance()->log_login_attempt("FiD Access"); 719 736 return new PipeEventReturn("", $parsed_response); 720 737 } … … 788 805 return new PipeEventReturn("", "Incorrect Login Credentials, please try again"); 789 806 } 790 do_action('wp_login', $user->user_login, $user);807 // do_action('wp_login', $user->user_login, $user); 791 808 return new PipeEventReturn("Login Successful"); 792 809 } … … 820 837 if (!$fid_user || $fid_user->user_id < 0) return new PipeEventReturn("", "Plugin user not found"); 821 838 822 if (!get_option(Options::$API_ KEY_ACCESS)) {839 if (!get_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR)) { 823 840 return new PipeEventReturn("", array( 824 841 "error" => "Invalid API key, please ensure you have activated the license from the FiD Auth settings page", … … 918 935 if (!$fid_user || $fid_user->user_id < 0) return new PipeEventReturn("", "Plugin user not found"); 919 936 920 if (!get_option(Options::$API_ KEY_ACCESS)) {937 if (!get_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR)) { 921 938 return new PipeEventReturn("", array( 922 939 "error" => "Invalid API key, please ensure you have activated the license from the FiD Auth settings page", -
qe-fid-id/trunk/includes/Utils/Networking.php
r2848772 r3261174 1 1 <?php 2 2 3 /** 3 4 * FiD Facial Recognition Admin Login … … 13 14 namespace QeFid\ID\Utils; 14 15 15 use QeFid\ID\ Constants\Options;16 use QeFid\ID\Models\Tokens; 16 17 17 class Networking{ 18 public static function post_to_url_with_image($url, $file_path, $form_data){ 19 $api_access_key = get_option(Options::$API_KEY_ACCESS); 20 $boundary = wp_generate_password( 24, false ); 18 class Networking 19 { 20 public static function post_to_url_with_image($url, $file_path, $form_data) 21 { 22 $api_access_key = Tokens::get_instance()->get_access_token(); 23 $boundary = wp_generate_password(24, false); 21 24 $headers = array( 22 25 'X-Api-Key' => $api_access_key, … … 25 28 26 29 $payload = ''; 27 foreach ( $form_data as $name => $value) {30 foreach ($form_data as $name => $value) { 28 31 $payload .= '--' . $boundary; 29 32 $payload .= "\r\n"; … … 35 38 36 39 // Upload the file 37 if ( $file_path) {40 if ($file_path) { 38 41 $payload .= '--' . $boundary; 39 42 $payload .= "\r\n"; 40 43 $payload .= 'Content-Disposition: form-data; name="' . 'file' . 41 '"; filename="' . basename( $file_path) . '"' . "\r\n";44 '"; filename="' . basename($file_path) . '"' . "\r\n"; 42 45 // $payload .= 'Content-Type: image/jpeg' . "\r\n"; 43 46 $payload .= "\r\n"; 44 $payload .= file_get_contents( $file_path);47 $payload .= file_get_contents($file_path); 45 48 $payload .= "\r\n"; 46 49 } 47 50 48 51 $payload .= '--' . $boundary . '--'; 49 $response = wp_remote_post( $url, 52 $response = wp_remote_post( 53 $url, 50 54 array( 51 55 'headers' => $headers, … … 57 61 } 58 62 59 public static function post_to_url($url, $body){ 60 $response = self::post_to_url_with_image($url,null,$body); 63 public static function post_to_url($url, $body) 64 { 65 $response = self::post_to_url_with_image($url, null, $body); 61 66 return $response; 62 67 } 63 64 68 } 65 ?> -
qe-fid-id/trunk/qe-fid-plugin.php
r3249351 r3261174 15 15 * Plugin URI: https://www.fidaccess.com 16 16 * Description: Secure your wp-admin with Facial recognition technology powered by FiD Access 17 * Version: 1.2. 717 * Version: 1.2.9 18 18 * Author: FiD Access 19 19 * Text Domain: qe-fid-v1 … … 65 65 66 66 add_action('wp_enqueue_scripts', 'QeFid\\ID\\collectiveray_load_js_script'); 67 68 $file = basename(__FILE__); 69 $folder = basename(dirname(__FILE__)); 70 $hook = "in_plugin_update_message-{$folder}/{$file}"; 71 72 function update_message_critical_updates_and_new_features($data, $response) 73 { 74 if (is_admin() && isset($data['upgrade_notice'])) { 75 printf( 76 '<div class="update-message">%s</div>', 77 wpautop($data['upgrade_notice']) 78 ); 79 } 80 } 81 add_action($hook, 'QeFid\\ID\\update_message_critical_updates_and_new_features', 10, 2); -
qe-fid-id/trunk/readme.txt
r3249351 r3261174 5 5 Tested up to: 6.7.2 6 6 Requires PHP: 5.6 7 Stable tag: 1.2. 77 Stable tag: 1.2.9 8 8 License: GPL-3.0 or later 9 9 License URI: https://www.gnu.org/licenses/gpl.html … … 190 190 191 191 == Changelog == 192 = 1.2.9 = 193 - Stability fixes and top 500 login attempts shown on dashboard 194 = 1.2.8 = 195 - Added login log to show top 10 logins to dashboard 192 196 = 1.2.7 = 193 197 - More Fixes for mobile capturing and wide lense cameras -
qe-fid-id/trunk/uninstall.php
r3184140 r3261174 6 6 use QeFid\ID\Constants\Options; 7 7 use QeFid\ID\Endpoint\PluginAdmin; 8 use QeFid\ID\Models\Tokens; 8 9 9 10 // If uninstall not called from WordPress exit … … 16 17 $access_key = get_option(\QeFid\ID\Constants\Options::$API_KEY_ACCESS); 17 18 $refresh_key = get_option(Options::$API_KEY_REFRESH); 18 if ($refresh_key) { 19 $refresh_pair = Tokens::get_instance(); 20 if ($refresh_key || $refresh_pair) { 19 21 try { 22 $refresh_key = ($refresh_pair !== false && gettype($refresh_pair) == 'object') ? $refresh_pair->get_refresh_token() : $refresh_key; 20 23 $deactivated = PluginAdmin::deactivate_license($refresh_key); 21 24 } catch (Exception $e) { … … 26 29 $deleted_endpoint = delete_option(Options::$FID_API_ENDPOINT); 27 30 $deleted_endpoint = delete_option(Options::$FID_LICENSE_USER_LIMIT); 31 $deleted_endpoint_key_pair = delete_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR); 28 32 } 29 33 delete_option(Options::$FID_LICENSE_KEY); … … 32 36 delete_option(Options::$FID_ADMIN_EMAIL); 33 37 delete_option(Options::$FID_PLUGIN_LOGIN_GUARD_STATE); 38 $deleted_endpoint_key_pair = delete_option(Options::$API_LICENCE_KEY_ACCESS_REFRESH_PAIR); 34 39 // Ensure that the user unenrolled from the service before deleting data 35 40 // protects against accidental deletion
Note: See TracChangeset
for help on using the changeset viewer.