Changeset 2522576
- Timestamp:
- 04/28/2021 08:53:27 AM (5 years ago)
- Location:
- integromat-connector/trunk
- Files:
-
- 5 edited
-
api/authentication.php (modified) (3 diffs)
-
class/Logger.php (modified) (3 diffs)
-
index.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
settings/render.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
integromat-connector/trunk/api/authentication.php
r2518111 r2522576 4 4 5 5 $skip = false; 6 $skipReason = []; 6 $codes = []; 7 $log = (get_option('iwc-logging-enabled') == 'true') ? true : false; 7 8 8 // Don't use our middleware when another authentication method is in use9 if (isset($_GET['consumer_key']) && isset($_GET['consumer_secret'])) {10 $skip = true;11 $skipReason[] = 'WooCommerce credentials provided.';12 }13 9 14 10 if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { 15 11 $skip = true; 16 $ skipReason[] = 'Basic Auth credentials provided.';12 $codes[] = 1; 17 13 } 18 14 19 15 if (is_user_logged_in()) { 20 16 $skip = true; 21 $ skipReason[] = 'User is logged in.';17 $codes[] = 2; 22 18 } 23 19 … … 25 21 if ($userId === 0) { 26 22 $skip = true; 27 $ skipReason[] = 'Can\'t find an admin user.';23 $codes[] = 3; 28 24 } 29 25 30 if (get_option('iwc-logging-enabled') == 'true') {31 \Integromat\Logger::write($skip, implode(' ', $skipReason));32 }33 34 // Skip our authorization and let the request pass through35 26 if ($skip) { 27 $log && \Integromat\Logger::write(implode(', ', $codes)); 36 28 return $result; 37 29 } … … 40 32 41 33 $token = $_SERVER['HTTP_IWC_API_KEY']; 34 42 35 if (strlen($token) !== \Integromat\ApiToken::API_TOKEN_LENGTH || !\Integromat\ApiToken::isValid($token)) { 36 $log && \Integromat\Logger::write(6); 43 37 \Integromat\RestResponse::renderError(401, 'Provided API key is invalid', 'invalid_token'); 44 38 } else { 45 39 \Integromat\User::login($userId); 40 $log && \Integromat\Logger::write(7); 41 \Integromat\RestRequest::dispatch(); 46 42 } 47 43 48 \Integromat\RestRequest::dispatch(); 44 } else { 45 if (\Integromat\Guard::isProtected()) { 46 $log && \Integromat\Logger::write(5); 47 \Integromat\RestResponse::renderError(401, 'API key is missing', 'missing_token'); 49 48 50 } else { 51 \Integromat\RestResponse::renderError(401, 'API key is missing', 'missing_token'); 49 } else { 50 $log && \Integromat\Logger::write(4); 51 return $result; 52 } 52 53 } 53 54 -
integromat-connector/trunk/class/Logger.php
r2518111 r2522576 79 79 80 80 81 private static function getRecord($ skip, $skipReason)81 private static function getRecord($codes) 82 82 { 83 83 $r = [ 84 'requestUri' => self::stripRequestQuery($_SERVER['REQUEST_URI']), 85 'clientIp' => $_SERVER['REMOTE_ADDR'], 86 'skipIwcAuth' => (string) $skip, 87 'skipReason' => $skipReason, 88 'userLogged' => (string) is_user_logged_in(), 84 'request' => $_SERVER['REQUEST_METHOD'] . ' ' . self::stripRequestQuery($_SERVER['REQUEST_URI']), 85 'ip' => $_SERVER['REMOTE_ADDR'], 86 'codes' => $codes . '(' . (string) is_user_logged_in() . ')', 89 87 ]; 90 88 $r = str_replace(['[', 'Array', ']'], '', print_r($r, true)); … … 94 92 95 93 96 public static function write($ skip, $skipReason)94 public static function write($codes) 97 95 { 98 96 self::check(); 99 97 $logData = self::getPlainFileContent(); 100 $newLogData = self::encrypt($logData . self::getRecord($ skip, $skipReason));98 $newLogData = self::encrypt($logData . self::getRecord($codes)); 101 99 file_put_contents(self::getFileLocation(), $newLogData); 102 100 } … … 117 115 $key = get_option('iwc_api_key'); 118 116 if (empty($key)) { 119 file_put_contents(self::getFileLocation(), 'iwc -api-key Not Found');117 file_put_contents(self::getFileLocation(), 'iwc_api_key Not Found'); 120 118 } 121 119 return $key; -
integromat-connector/trunk/index.php
r2518111 r2522576 3 3 /** 4 4 * @package Integromat_Connector 5 * @version 1. 35 * @version 1.4 6 6 */ 7 7 … … 11 11 Author: Integromat 12 12 Author URI: https://www.integromat.com/ 13 Version: 1. 313 Version: 1.4 14 14 */ 15 15 … … 22 22 include __DIR__ . '/class/RestResponse.php'; 23 23 include __DIR__ . '/class/ApiToken.php'; 24 include __DIR__ . '/class/Guard.php'; 24 25 include __DIR__ . '/class/Logger.php'; 25 26 -
integromat-connector/trunk/readme.txt
r2518111 r2522576 5 5 Tested up to: 5.7 6 6 Requires PHP: 5.6 7 Stable tag: 1. 27 Stable tag: 1.4 8 8 License: GPLv2 or later 9 9 … … 24 24 == Changelog == 25 25 26 = 1.4 = 27 * Enhanced API calls logging 28 * Fixed blocking of some internal API calls 29 26 30 = 1.3 = 27 31 * Added possibility of API calls logging -
integromat-connector/trunk/settings/render.php
r2476182 r2522576 18 18 include_once __DIR__ . '/template/connector.phtml'; 19 19 }, 20 plugin_dir_url('') . IWC_PLUGIN_NAME_SAFE . '/assets/integromat-white.svg'20 plugin_dir_url('') . '/integromat-connector/assets/integromat-white.svg' 21 21 ); 22 22
Note: See TracChangeset
for help on using the changeset viewer.