Plugin Directory

Changeset 2522576


Ignore:
Timestamp:
04/28/2021 08:53:27 AM (5 years ago)
Author:
integromat
Message:

v1.4

Location:
integromat-connector/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • integromat-connector/trunk/api/authentication.php

    r2518111 r2522576  
    44
    55    $skip = false;
    6     $skipReason = [];
     6    $codes = [];
     7    $log = (get_option('iwc-logging-enabled') == 'true') ? true : false;
    78
    8     // Don't use our middleware when another authentication method is in use
    9     if (isset($_GET['consumer_key']) && isset($_GET['consumer_secret'])) {
    10         $skip = true;
    11         $skipReason[] = 'WooCommerce credentials provided.';
    12     }
    139
    1410    if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
    1511        $skip = true;
    16         $skipReason[] = 'Basic Auth credentials provided.';
     12        $codes[] = 1;
    1713    }
    1814
    1915    if (is_user_logged_in()) {
    2016        $skip = true;
    21         $skipReason[] = 'User is logged in.';
     17        $codes[] = 2;
    2218    }
    2319
     
    2521    if ($userId === 0) {
    2622        $skip = true;
    27         $skipReason[] = 'Can\'t find an admin user.';
     23        $codes[] = 3;
    2824    }
    2925
    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 through
    3526    if ($skip) {
     27        $log && \Integromat\Logger::write(implode(', ', $codes));
    3628        return $result;
    3729    }
     
    4032
    4133        $token = $_SERVER['HTTP_IWC_API_KEY'];
     34
    4235        if (strlen($token) !== \Integromat\ApiToken::API_TOKEN_LENGTH || !\Integromat\ApiToken::isValid($token)) {
     36            $log && \Integromat\Logger::write(6);
    4337            \Integromat\RestResponse::renderError(401, 'Provided API key is invalid', 'invalid_token');
    4438        } else {
    4539            \Integromat\User::login($userId);
     40            $log && \Integromat\Logger::write(7);
     41            \Integromat\RestRequest::dispatch();
    4642        }
    4743
    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');
    4948
    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        }
    5253    }
    5354
  • integromat-connector/trunk/class/Logger.php

    r2518111 r2522576  
    7979
    8080
    81     private static function getRecord($skip, $skipReason)
     81    private static function getRecord($codes)
    8282    {
    8383        $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() . ')',
    8987        ];
    9088        $r = str_replace(['[', 'Array', ']'], '', print_r($r, true));
     
    9492
    9593
    96     public static function write($skip, $skipReason)
     94    public static function write($codes)
    9795    {
    9896        self::check();
    9997        $logData = self::getPlainFileContent();
    100         $newLogData = self::encrypt($logData . self::getRecord($skip, $skipReason));
     98        $newLogData = self::encrypt($logData . self::getRecord($codes));
    10199        file_put_contents(self::getFileLocation(), $newLogData);
    102100    }
     
    117115        $key = get_option('iwc_api_key');
    118116        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');
    120118        }
    121119        return $key;
  • integromat-connector/trunk/index.php

    r2518111 r2522576  
    33/**
    44 * @package Integromat_Connector
    5  * @version 1.3
     5 * @version 1.4
    66 */
    77
     
    1111Author: Integromat
    1212Author URI: https://www.integromat.com/
    13 Version: 1.3
     13Version: 1.4
    1414*/
    1515
     
    2222include __DIR__ . '/class/RestResponse.php';
    2323include __DIR__ . '/class/ApiToken.php';
     24include __DIR__ . '/class/Guard.php';
    2425include __DIR__ . '/class/Logger.php';
    2526
  • integromat-connector/trunk/readme.txt

    r2518111 r2522576  
    55Tested up to: 5.7
    66Requires PHP: 5.6
    7 Stable tag: 1.2
     7Stable tag: 1.4
    88License: GPLv2 or later
    99
     
    2424== Changelog ==
    2525
     26= 1.4 =
     27* Enhanced API calls logging
     28* Fixed blocking of some internal API calls
     29
    2630= 1.3 =
    2731* Added possibility of API calls logging
  • integromat-connector/trunk/settings/render.php

    r2476182 r2522576  
    1818            include_once __DIR__ . '/template/connector.phtml';
    1919        },
    20         plugin_dir_url('') . IWC_PLUGIN_NAME_SAFE . '/assets/integromat-white.svg'
     20        plugin_dir_url('') . '/integromat-connector/assets/integromat-white.svg'
    2121    );
    2222
Note: See TracChangeset for help on using the changeset viewer.