Changeset 3483307
- Timestamp:
- 03/15/2026 09:21:36 PM (2 weeks ago)
- Location:
- flowsystems-webhook-actions
- Files:
-
- 7 added
- 2 deleted
- 12 edited
-
assets/screenshot-8.png (added)
-
trunk/README.txt (modified) (7 diffs)
-
trunk/admin/dist/.vite/manifest.json (modified) (2 diffs)
-
trunk/admin/dist/assets/main-C1bVA2d5.js (added)
-
trunk/admin/dist/assets/main-oBfATGcf.js (deleted)
-
trunk/admin/dist/assets/style-BckjMVPE.css (deleted)
-
trunk/admin/dist/assets/style-BgO0BuI6.css (added)
-
trunk/flowsystems-webhook-actions.php (modified) (2 diffs)
-
trunk/src/Activation.php (modified) (3 diffs)
-
trunk/src/Api/ApiTokensController.php (added)
-
trunk/src/Api/AuthHelper.php (added)
-
trunk/src/Api/HealthController.php (modified) (2 diffs)
-
trunk/src/Api/LogsController.php (modified) (5 diffs)
-
trunk/src/Api/QueueController.php (modified) (7 diffs)
-
trunk/src/Api/SchemasController.php (modified) (7 diffs)
-
trunk/src/Api/TriggersController.php (modified) (2 diffs)
-
trunk/src/Api/WebhooksController.php (modified) (3 diffs)
-
trunk/src/Controllers/AdminController.php (modified) (2 diffs)
-
trunk/src/Database/Migrator.php (modified) (4 diffs)
-
trunk/src/Repositories/ApiTokenRepository.php (added)
-
trunk/src/Services/ApiTokenService.php (added)
Legend:
- Unmodified
- Added
- Removed
-
flowsystems-webhook-actions/trunk/README.txt
r3477178 r3483307 1 1 === Flow Systems Webhook Actions === 2 2 Contributors: mateuszflowsystems 3 Tags: webhook , automation, integration, n8n, api3 Tags: webhooks, automation, integration, n8n, api 4 4 Requires at least: 6.0 5 5 Tested up to: 6.9 6 6 Requires PHP: 8.0 7 Stable tag: 1. 2.17 Stable tag: 1.3.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html … … 34 34 - Replace fragile custom `wp_remote_post()` integrations 35 35 - Build idempotent WordPress automation pipelines 36 - Query delivery logs, trigger retries, or manage webhooks programmatically from CI/CD pipelines or external dashboards using API tokens 37 - Allow AI coding assistants (e.g. Claude Code) to inspect webhook logs and retry failed events automatically 38 - Use AI agents to monitor webhook delivery health and operate the queue through the REST API 36 39 37 40 = Event Identity & Idempotency = … … 113 116 Payloads always include stable event metadata for consistency. 114 117 118 = REST API Access with Token Authentication = 119 120 The plugin exposes a full operational REST API (`/wp-json/fswa/v1/`) that powers the admin interface and can also be used directly by external tools, automation systems, AI agents, and CI/CD pipelines. 121 122 Every endpoint supports dual authentication: 123 124 - WordPress admin session (cookie-based, used by the admin panel) 125 - API token — for programmatic access without a browser session 126 127 **API Tokens** 128 129 Create tokens directly from the API Tokens screen in the admin panel. Each token is assigned one of three scopes: 130 131 - `read` — GET access to webhooks, logs, queue, health, triggers, and schemas 132 - `operational` — Read + toggle webhooks on/off, retry and replay log entries, execute queue jobs 133 - `full` — Operational + create, update, and delete webhooks, schemas, and queue jobs 134 135 Token authentication is accepted via: 136 137 - `X-FSWA-Token: <token>` header (recommended) 138 - `Authorization: Bearer <token>` header 139 - `?api_token=<token>` query parameter 140 141 Tokens can be set to expire and rotated at any time. Rotation issues a new secret immediately while preserving the token's name, scope, and settings. Token management always requires a WordPress admin login — tokens cannot be used to create or manage other tokens. 142 143 Full REST API documentation: https://flowsystems.pl/webhook-wordpress-plugin-api/ 144 145 = AI Agents and Programmatic Automation = 146 147 The REST API makes Flow Systems Webhook Actions accessible to AI-powered tools and coding agents. 148 149 Automation systems, CI pipelines, and AI coding assistants (such as Claude Code or Cursor) can safely interact with webhook infrastructure using API tokens without requiring WordPress admin sessions. 150 151 Typical AI-driven workflows include: 152 153 - AI agents monitoring webhook delivery health 154 - Automatically retrying failed webhook events 155 - Inspecting delivery logs to debug integrations 156 - Enabling or disabling webhooks dynamically during deployments 157 - Managing automation pipelines across environments 158 159 Because the API exposes operational endpoints for logs, queue jobs, webhooks, and triggers, external agents can treat WordPress as a programmable event infrastructure. 160 161 Example scenarios: 162 163 • A Claude Code agent analyzes webhook delivery logs and automatically retries failed integrations. 164 • A CI/CD pipeline disables webhook triggers during deployments and re-enables them afterward. 165 • Automation systems query webhook health metrics and alert when the queue becomes stuck. 166 • External dashboards display real-time webhook delivery metrics using API tokens. 167 168 This allows WordPress automation pipelines to be controlled entirely through HTTP APIs, enabling advanced integration with AI-driven development workflows. 169 115 170 = Developer Friendly = 116 171 117 172 - Works with any WordPress or WooCommerce action 118 - Internal REST endpoints power the admin interface 173 - Full REST API (`/wp-json/fswa/v1/`) usable from any HTTP client — not just the admin panel 174 - API token authentication with scoped access (`read`, `operational`, `full`) 119 175 - Fully extensible via filters and actions 120 176 - Clean namespace and unique prefixes … … 134 190 - Event UUIDs and timestamps 135 191 - Full delivery logging and metrics 192 - REST API with token authentication for programmatic access 136 193 137 194 Built for developers who need production-grade automation reliability. … … 193 250 Yes. For user-related triggers (such as `user_register`, `profile_update`, `wp_login`, `wp_logout`), you can enable "Include User Data" to automatically add user information (ID, email, display name, roles, etc.) to the payload. 194 251 252 = Can I access the REST API without a WordPress login? = 253 254 Yes. Create an API token from the API Tokens screen in the admin panel and use it in the `X-FSWA-Token` header (or `Authorization: Bearer`) with your requests. Tokens support three scopes — `read`, `operational`, and `full` — so you can grant only the access level each integration needs. 255 195 256 = Is this plugin free? = 196 257 … … 206 267 6. Queue status overview 207 268 7. Settings configuration screen 269 8. REST API Tokens configuration screen 208 270 209 271 == Changelog == 272 273 = 1.3.0 — 2026-03-15 = 274 - Added API token authentication for the REST API — create tokens with `read`, `operational`, or `full` scope; tokens are SHA-256 hashed at rest and accepted via `X-FSWA-Token` header, `Authorization: Bearer`, or `?api_token=` query param 275 - Added token expiry support with optional `expires_at`; expired tokens are rejected at auth time and visually flagged in the admin panel 276 - Added token rotation — issues a new secret while preserving all other token fields; optionally updates expiry in the same request; revived expired tokens auto-extend to +30 days by default 277 - Added `PATCH /tokens/{id}` endpoint for updating `expires_at` independently of rotation 278 - Added `fswa_api_tokens` database table (migration 1.3.0) 279 - Applied scope-based dual auth (`manage_options` session OR valid token) to all existing REST controllers: `read` for GET endpoints, `operational` for toggle/retry/replay, `full` for create/update/delete 280 - Fixed all admin UI date displays (logs, queue, schema panel) to show times in the user's local timezone instead of raw UTC 281 - Fixed date range filters (logs, queue) to correctly convert local picker values to UTC before querying 282 - Improved log details panel — error message, response body, HTTP code, and duration now reflect the most recent attempt history entry rather than the top-level log fields 210 283 211 284 = 1.2.1 — 2026-03-07 = … … 255 328 == Upgrade Notice == 256 329 330 = 1.3.0 = 331 Adds a new database table for API tokens. The table is created automatically on update — no manual steps needed. 332 257 333 = 1.1.1 = 258 334 Fixes permanently_failed entries being undercounted in delivery statistics. No database changes. -
flowsystems-webhook-actions/trunk/admin/dist/.vite/manifest.json
r3477165 r3483307 1 1 { 2 2 "src/main.js": { 3 "file": "assets/main- oBfATGcf.js",3 "file": "assets/main-C1bVA2d5.js", 4 4 "name": "main", 5 5 "src": "src/main.js", … … 7 7 }, 8 8 "style.css": { 9 "file": "assets/style-B ckjMVPE.css",9 "file": "assets/style-BgO0BuI6.css", 10 10 "src": "style.css" 11 11 } -
flowsystems-webhook-actions/trunk/flowsystems-webhook-actions.php
r3477178 r3483307 4 4 * Plugin URI: https://flowsystems.pl/wordpress-webhook-actions 5 5 * Description: Trigger HTTP webhooks from WordPress actions (do_action). Easily connect WordPress with n8n, Zapier, Make, or custom workflows. 6 * Version: 1. 2.16 * Version: 1.3.0 7 7 * Author: Mateusz Skorupa 8 8 * Author URI: https://flowsystems.pl … … 17 17 defined('ABSPATH') || exit; 18 18 19 define('FSWA_VERSION', '1. 2.1');19 define('FSWA_VERSION', '1.3.0'); 20 20 define('FSWA_FILE', __FILE__); 21 21 -
flowsystems-webhook-actions/trunk/src/Activation.php
r3477165 r3483307 22 22 23 23 $charsetCollate = $wpdb->get_charset_collate(); 24 $webhooksTable = $wpdb->prefix . 'fswa_webhooks'; 25 $triggersTable = $wpdb->prefix . 'fswa_webhook_triggers'; 26 $logsTable = $wpdb->prefix . 'fswa_logs'; 27 $queueTable = $wpdb->prefix . 'fswa_queue'; 28 $statsTable = $wpdb->prefix . 'fswa_stats'; 24 $webhooksTable = $wpdb->prefix . 'fswa_webhooks'; 25 $triggersTable = $wpdb->prefix . 'fswa_webhook_triggers'; 26 $logsTable = $wpdb->prefix . 'fswa_logs'; 27 $queueTable = $wpdb->prefix . 'fswa_queue'; 28 $statsTable = $wpdb->prefix . 'fswa_stats'; 29 $apiTokensTable = $wpdb->prefix . 'fswa_api_tokens'; 29 30 30 31 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; … … 127 128 dbDelta($sqlStats); 128 129 129 update_option('fswa_db_version', '1.2.0'); 130 // API tokens table 131 $sqlApiTokens = "CREATE TABLE {$apiTokensTable} ( 132 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 133 name VARCHAR(255) NOT NULL, 134 token_hash VARCHAR(64) NOT NULL, 135 token_hint VARCHAR(13) NOT NULL, 136 scope VARCHAR(20) NOT NULL DEFAULT 'read', 137 expires_at DATETIME DEFAULT NULL, 138 last_used_at DATETIME DEFAULT NULL, 139 rotated_at DATETIME DEFAULT NULL, 140 created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 141 PRIMARY KEY (id), 142 UNIQUE KEY idx_token_hash (token_hash), 143 KEY idx_expires (expires_at) 144 ) {$charsetCollate};"; 145 146 dbDelta($sqlApiTokens); 147 148 update_option('fswa_db_version', '1.3.0'); 130 149 } 131 150 … … 176 195 // Drop tables (order matters for foreign key constraints) 177 196 // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 197 $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}fswa_api_tokens"); 178 198 $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}fswa_stats"); 179 199 $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}fswa_queue"); -
flowsystems-webhook-actions/trunk/src/Api/HealthController.php
r3477165 r3483307 13 13 use FlowSystems\WebhookActions\Services\QueueService; 14 14 use FlowSystems\WebhookActions\Services\StatsService; 15 use FlowSystems\WebhookActions\Api\AuthHelper; 16 use WP_Error; 15 17 16 18 class HealthController extends WP_REST_Controller { … … 45 47 } 46 48 47 /** 48 * Check permissions 49 */ 50 public function permissionsCheck($request): bool { 51 return current_user_can('manage_options'); 49 public function permissionsCheck($request): bool|WP_Error { 50 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_READ); 52 51 } 53 52 -
flowsystems-webhook-actions/trunk/src/Api/LogsController.php
r3477165 r3483307 15 15 use FlowSystems\WebhookActions\Repositories\WebhookRepository; 16 16 use FlowSystems\WebhookActions\Services\QueueService; 17 use FlowSystems\WebhookActions\Api\AuthHelper; 17 18 18 19 class LogsController extends WP_REST_Controller { … … 79 80 'methods' => WP_REST_Server::CREATABLE, 80 81 'callback' => [$this, 'retryItem'], 81 'permission_callback' => [$this, ' getItemPermissionsCheck'],82 'permission_callback' => [$this, 'operationalPermissionsCheck'], 82 83 ], 83 84 ]); … … 87 88 'methods' => WP_REST_Server::CREATABLE, 88 89 'callback' => [$this, 'replayItem'], 89 'permission_callback' => [$this, ' getItemPermissionsCheck'],90 'permission_callback' => [$this, 'operationalPermissionsCheck'], 90 91 ]]); 91 92 … … 95 96 'methods' => WP_REST_Server::CREATABLE, 96 97 'callback' => [$this, 'bulkRetry'], 97 'permission_callback' => [$this, ' getItemsPermissionsCheck'],98 'permission_callback' => [$this, 'operationalPermissionsCheck'], 98 99 'args' => [ 99 100 'ids' => [ … … 137 138 } 138 139 139 /** 140 * Check permissions for getting items 141 */ 142 public function getItemsPermissionsCheck($request): bool { 143 return current_user_can('manage_options'); 144 } 145 146 /** 147 * Check permissions for getting single item 148 */ 149 public function getItemPermissionsCheck($request): bool { 150 return current_user_can('manage_options'); 151 } 152 153 /** 154 * Check permissions for deleting items 155 */ 156 public function deleteItemsPermissionsCheck($request): bool { 157 return current_user_can('manage_options'); 158 } 159 160 /** 161 * Check permissions for deleting single item 162 */ 163 public function deleteItemPermissionsCheck($request): bool { 164 return current_user_can('manage_options'); 140 public function getItemsPermissionsCheck($request): bool|WP_Error { 141 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_READ); 142 } 143 144 public function getItemPermissionsCheck($request): bool|WP_Error { 145 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_READ); 146 } 147 148 public function operationalPermissionsCheck($request): bool|WP_Error { 149 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_OPERATIONAL); 150 } 151 152 public function deleteItemsPermissionsCheck($request): bool|WP_Error { 153 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_FULL); 154 } 155 156 public function deleteItemPermissionsCheck($request): bool|WP_Error { 157 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_FULL); 165 158 } 166 159 -
flowsystems-webhook-actions/trunk/src/Api/QueueController.php
r3477165 r3483307 14 14 use FlowSystems\WebhookActions\Services\WPHttpTransport; 15 15 use FlowSystems\WebhookActions\Repositories\WebhookRepository; 16 use FlowSystems\WebhookActions\Api\AuthHelper; 16 17 17 18 class QueueController extends WP_REST_Controller { … … 31 32 'methods' => WP_REST_Server::READABLE, 32 33 'callback' => [$this, 'getItems'], 33 'permission_callback' => [$this, ' permissionsCheck'],34 'permission_callback' => [$this, 'readPermissionsCheck'], 34 35 'args' => [ 35 36 'status' => [ … … 72 73 'methods' => WP_REST_Server::READABLE, 73 74 'callback' => [$this, 'getStats'], 74 'permission_callback' => [$this, ' permissionsCheck'],75 'permission_callback' => [$this, 'readPermissionsCheck'], 75 76 ], 76 77 ]); … … 81 82 'methods' => WP_REST_Server::CREATABLE, 82 83 'callback' => [$this, 'executeItem'], 83 'permission_callback' => [$this, ' permissionsCheck'],84 'permission_callback' => [$this, 'operationalPermissionsCheck'], 84 85 'args' => [ 85 86 'id' => [ … … 96 97 'methods' => WP_REST_Server::CREATABLE, 97 98 'callback' => [$this, 'deleteItem'], 98 'permission_callback' => [$this, ' permissionsCheck'],99 'permission_callback' => [$this, 'fullPermissionsCheck'], 99 100 'args' => [ 100 101 'id' => [ … … 111 112 'methods' => WP_REST_Server::CREATABLE, 112 113 'callback' => [$this, 'retryItem'], 113 'permission_callback' => [$this, ' permissionsCheck'],114 'permission_callback' => [$this, 'operationalPermissionsCheck'], 114 115 'args' => [ 115 116 'id' => [ … … 122 123 } 123 124 124 public function permissionsCheck(WP_REST_Request $_request): bool { 125 return current_user_can('manage_options'); 125 public function readPermissionsCheck(WP_REST_Request $request): bool|WP_Error { 126 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_READ); 127 } 128 129 public function operationalPermissionsCheck(WP_REST_Request $request): bool|WP_Error { 130 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_OPERATIONAL); 131 } 132 133 public function fullPermissionsCheck(WP_REST_Request $request): bool|WP_Error { 134 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_FULL); 126 135 } 127 136 -
flowsystems-webhook-actions/trunk/src/Api/SchemasController.php
r3462891 r3483307 13 13 use FlowSystems\WebhookActions\Repositories\WebhookRepository; 14 14 use FlowSystems\WebhookActions\Services\PayloadTransformer; 15 use FlowSystems\WebhookActions\Api\AuthHelper; 15 16 16 17 class SchemasController extends WP_REST_Controller { … … 37 38 'methods' => WP_REST_Server::READABLE, 38 39 'callback' => [$this, 'getWebhookSchemas'], 39 'permission_callback' => [$this, ' permissionsCheck'],40 'permission_callback' => [$this, 'readPermissionsCheck'], 40 41 'args' => [ 41 42 'id' => [ … … 53 54 'methods' => WP_REST_Server::READABLE, 54 55 'callback' => [$this, 'getSchema'], 55 'permission_callback' => [$this, ' permissionsCheck'],56 'permission_callback' => [$this, 'readPermissionsCheck'], 56 57 'args' => [ 57 58 'id' => [ … … 70 71 'methods' => WP_REST_Server::EDITABLE, 71 72 'callback' => [$this, 'updateSchema'], 72 'permission_callback' => [$this, ' permissionsCheck'],73 'permission_callback' => [$this, 'fullPermissionsCheck'], 73 74 'args' => [ 74 75 'id' => [ … … 95 96 'methods' => WP_REST_Server::DELETABLE, 96 97 'callback' => [$this, 'deleteSchema'], 97 'permission_callback' => [$this, ' permissionsCheck'],98 'permission_callback' => [$this, 'fullPermissionsCheck'], 98 99 'args' => [ 99 100 'id' => [ … … 116 117 'methods' => WP_REST_Server::CREATABLE, 117 118 'callback' => [$this, 'resetCapture'], 118 'permission_callback' => [$this, ' permissionsCheck'],119 'permission_callback' => [$this, 'fullPermissionsCheck'], 119 120 'args' => [ 120 121 'id' => [ … … 137 138 'methods' => WP_REST_Server::READABLE, 138 139 'callback' => [$this, 'getUserTriggers'], 139 'permission_callback' => [$this, 'permissionsCheck'], 140 ], 141 ]); 142 } 143 144 /** 145 * Permission check 146 */ 147 public function permissionsCheck($request): bool { 148 return current_user_can('manage_options'); 140 'permission_callback' => [$this, 'readPermissionsCheck'], 141 ], 142 ]); 143 } 144 145 public function readPermissionsCheck($request): bool|WP_Error { 146 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_READ); 147 } 148 149 public function fullPermissionsCheck($request): bool|WP_Error { 150 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_FULL); 149 151 } 150 152 -
flowsystems-webhook-actions/trunk/src/Api/TriggersController.php
r3464666 r3483307 8 8 use WP_REST_Server; 9 9 use WP_REST_Response; 10 use WP_Error; 11 use FlowSystems\WebhookActions\Api\AuthHelper; 10 12 11 13 class TriggersController extends WP_REST_Controller { … … 24 26 } 25 27 26 /** 27 * Check permissions 28 */ 29 public function getItemsPermissionsCheck($request): bool { 30 return current_user_can('manage_options'); 28 public function getItemsPermissionsCheck($request): bool|WP_Error { 29 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_READ); 31 30 } 32 31 -
flowsystems-webhook-actions/trunk/src/Api/WebhooksController.php
r3462891 r3483307 11 11 use WP_Error; 12 12 use FlowSystems\WebhookActions\Repositories\WebhookRepository; 13 use FlowSystems\WebhookActions\Api\AuthHelper; 13 14 14 15 class WebhooksController extends WP_REST_Controller { … … 71 72 'methods' => WP_REST_Server::CREATABLE, 72 73 'callback' => [$this, 'toggleItem'], 73 'permission_callback' => [$this, ' updateItemPermissionsCheck'],74 'permission_callback' => [$this, 'toggleItemPermissionsCheck'], 74 75 'args' => [ 75 76 'id' => [ … … 81 82 } 82 83 83 /** 84 * Check permissions for getting items 85 */ 86 public function getItemsPermissionsCheck($request): bool { 87 return current_user_can('manage_options'); 88 } 89 90 /** 91 * Check permissions for getting single item 92 */ 93 public function getItemPermissionsCheck($request): bool { 94 return current_user_can('manage_options'); 95 } 96 97 /** 98 * Check permissions for creating items 99 */ 100 public function createItemPermissionsCheck($request): bool { 101 return current_user_can('manage_options'); 102 } 103 104 /** 105 * Check permissions for updating items 106 */ 107 public function updateItemPermissionsCheck($request): bool { 108 return current_user_can('manage_options'); 109 } 110 111 /** 112 * Check permissions for deleting items 113 */ 114 public function deleteItemPermissionsCheck($request): bool { 115 return current_user_can('manage_options'); 84 public function getItemsPermissionsCheck($request): bool|WP_Error { 85 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_READ); 86 } 87 88 public function getItemPermissionsCheck($request): bool|WP_Error { 89 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_READ); 90 } 91 92 public function createItemPermissionsCheck($request): bool|WP_Error { 93 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_FULL); 94 } 95 96 public function updateItemPermissionsCheck($request): bool|WP_Error { 97 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_FULL); 98 } 99 100 public function toggleItemPermissionsCheck($request): bool|WP_Error { 101 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_OPERATIONAL); 102 } 103 104 public function deleteItemPermissionsCheck($request): bool|WP_Error { 105 return AuthHelper::dualAuth($request, AuthHelper::SCOPE_FULL); 116 106 } 117 107 -
flowsystems-webhook-actions/trunk/src/Controllers/AdminController.php
r3462891 r3483307 13 13 use FlowSystems\WebhookActions\Api\HealthController; 14 14 use FlowSystems\WebhookActions\Api\SchemasController; 15 use FlowSystems\WebhookActions\Api\ApiTokensController; 15 16 16 17 class AdminController { … … 163 164 (new HealthController())->registerRoutes(); 164 165 (new SchemasController())->registerRoutes(); 166 (new ApiTokensController())->registerRoutes(); 165 167 } 166 168 -
flowsystems-webhook-actions/trunk/src/Database/Migrator.php
r3477165 r3483307 5 5 class Migrator { 6 6 private const OPTION_KEY = 'fswa_db_version'; 7 private const CURRENT_VERSION = '1. 2.0';7 private const CURRENT_VERSION = '1.3.0'; 8 8 9 9 /** … … 45 45 $wpdb->prefix . 'fswa_trigger_schemas', 46 46 $wpdb->prefix . 'fswa_stats', 47 $wpdb->prefix . 'fswa_api_tokens', 47 48 ]; 48 49 … … 68 69 '1.1.0' => [self::class, 'migration_1_1_0'], 69 70 '1.2.0' => [self::class, 'migration_1_2_0'], 71 '1.3.0' => [self::class, 'migration_1_3_0'], 70 72 ]; 71 73 } … … 265 267 266 268 /** 269 * Migration 1.3.0 - Add API tokens table 270 */ 271 public static function migration_1_3_0(): void { 272 global $wpdb; 273 274 $charsetCollate = $wpdb->get_charset_collate(); 275 $tokensTable = $wpdb->prefix . 'fswa_api_tokens'; 276 277 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 278 279 $sql = "CREATE TABLE {$tokensTable} ( 280 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 281 name VARCHAR(255) NOT NULL, 282 token_hash VARCHAR(64) NOT NULL, 283 token_hint VARCHAR(13) NOT NULL, 284 scope VARCHAR(20) NOT NULL DEFAULT 'read', 285 expires_at DATETIME DEFAULT NULL, 286 last_used_at DATETIME DEFAULT NULL, 287 rotated_at DATETIME DEFAULT NULL, 288 created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 289 PRIMARY KEY (id), 290 UNIQUE KEY idx_token_hash (token_hash), 291 KEY idx_expires (expires_at) 292 ) {$charsetCollate};"; 293 294 dbDelta($sql); 295 } 296 297 /** 267 298 * Get current database version 268 299 */
Note: See TracChangeset
for help on using the changeset viewer.