Plugin Directory

Changeset 3483325


Ignore:
Timestamp:
03/15/2026 10:34:35 PM (2 weeks ago)
Author:
mateuszflowsystems
Message:

Release 1.3.2

Location:
flowsystems-webhook-actions/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • flowsystems-webhook-actions/trunk/README.txt

    r3483320 r3483325  
    55Tested up to: 6.9
    66Requires PHP: 8.0
    7 Stable tag: 1.3.1
     7Stable tag: 1.3.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     
    270270
    271271== Changelog ==
     272
     273= 1.3.2 — 2026-03-15 =
     274- Fixed `auth_header` field being exposed to API tokens without `full` scope — read and operational tokens now receive a permission notice instead
    272275
    273276= 1.3.1 — 2026-03-15 =
  • flowsystems-webhook-actions/trunk/flowsystems-webhook-actions.php

    r3483320 r3483325  
    44 * Plugin URI: https://flowsystems.pl/wordpress-webhook-actions
    55 * Description: Trigger HTTP webhooks from WordPress actions (do_action). Easily connect WordPress with n8n, Zapier, Make, or custom workflows.
    6  * Version: 1.3.1
     6 * Version: 1.3.2
    77 * Author: Mateusz Skorupa
    88 * Author URI: https://flowsystems.pl
     
    1717defined('ABSPATH') || exit;
    1818
    19 define('FSWA_VERSION', '1.3.1');
     19define('FSWA_VERSION', '1.3.2');
    2020define('FSWA_FILE', __FILE__);
    2121
  • flowsystems-webhook-actions/trunk/src/Api/AuthHelper.php

    r3483307 r3483325  
    5555    return true;
    5656  }
     57
     58  /**
     59   * Check if the current request has at least the given scope (or is an admin session).
     60   * Use this for response shaping — does not send errors.
     61   */
     62  public static function requestHasScope(WP_REST_Request $request, string $scope): bool {
     63    if (current_user_can('manage_options')) {
     64      return true;
     65    }
     66
     67    $service = new ApiTokenService();
     68    $token   = $service->validateFromRequest($request);
     69
     70    if ($token === false) {
     71      return false;
     72    }
     73
     74    return $service->tokenHasScope($token, $scope);
     75  }
    5776}
  • flowsystems-webhook-actions/trunk/src/Api/WebhooksController.php

    r3483307 r3483325  
    107107
    108108  /**
     109   * Strip auth_header for non-full-scope callers.
     110   */
     111  private function prepareWebhook(array $webhook, WP_REST_Request $request): array {
     112    if (!AuthHelper::requestHasScope($request, AuthHelper::SCOPE_FULL)) {
     113      $webhook['auth_header'] = __('You don\'t have permissions to see it.', 'flowsystems-webhook-actions');
     114    }
     115    return $webhook;
     116  }
     117
     118  /**
    109119   * Get all webhooks
    110120   */
    111121  public function getItems($request): WP_REST_Response {
    112122    $webhooks = $this->repository->getAll();
     123    $webhooks = array_map(fn($w) => $this->prepareWebhook($w, $request), $webhooks);
    113124
    114125    return rest_ensure_response($webhooks);
     
    130141    }
    131142
    132     return rest_ensure_response($webhook);
     143    return rest_ensure_response($this->prepareWebhook($webhook, $request));
    133144  }
    134145
     
    185196    $webhook = $this->repository->find($webhookId);
    186197
    187     return rest_ensure_response($webhook);
     198    return rest_ensure_response($this->prepareWebhook($webhook, $request));
    188199  }
    189200
     
    245256    $webhook = $this->repository->find($id);
    246257
    247     return rest_ensure_response($webhook);
     258    return rest_ensure_response($this->prepareWebhook($webhook, $request));
    248259  }
    249260
     
    304315    $webhook = $this->repository->find($id);
    305316
    306     return rest_ensure_response($webhook);
     317    return rest_ensure_response($this->prepareWebhook($webhook, $request));
    307318  }
    308319
Note: See TracChangeset for help on using the changeset viewer.