diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..877085a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# Keeps the pinned GitHub Actions (commit SHAs in .github/workflows) up to date. +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly + groups: + github-actions: + patterns: + - '*' diff --git a/.github/workflows/assets.yml b/.github/workflows/assets.yml new file mode 100644 index 0000000..8479b14 --- /dev/null +++ b/.github/workflows/assets.yml @@ -0,0 +1,47 @@ +name: Update readme and assets + +# Publishes changes to readme.txt (e.g. "Tested up to") and .wordpress-org/ +# to wordpress.org without a new version. Code changes still need a release +# (see release.yml) – the deploy action stops if anything else in the package +# differs from SVN trunk. + +on: + push: + branches: [main] + paths: + - readme.txt + - .wordpress-org/** + workflow_dispatch: + +permissions: + contents: read + +jobs: + update: + name: Update readme and assets on wordpress.org + runs-on: ubuntu-latest + environment: wordpress.org + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + + # A release bumps the version on main before its tag is pushed; + # release.yml deploys that version, so there is nothing to do here. + - name: Check that the version is released + id: released + run: | + version=$(sed -n 's/^Version: *//p' wirecore-rest-control.php | tr -d '\r') + if curl -sfI "https://plugins.svn.wordpress.org/wirecore-rest-control/tags/$version/" > /dev/null; then + echo "released=true" >> "$GITHUB_OUTPUT" + else + echo "::notice::Version $version is not on wordpress.org yet; release.yml deploys it." + echo "released=false" >> "$GITHUB_OUTPUT" + fi + + - name: Update readme and assets + if: steps.released.outputs.released == 'true' + uses: 10up/action-wordpress-plugin-asset-update@2480306f6f693672726d08b5917ea114cb2825f7 # 2.2.0 + env: + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + SLUG: wirecore-rest-control + ASSETS_DIR: .wordpress-org diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44dfabf..f1f1282 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,8 @@ jobs: # Keep in sync with the tests below and "Requires PHP" (7.4) php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] steps: - - uses: actions/checkout@v4 - - uses: shivammathur/setup-php@v2 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 with: php-version: ${{ matrix.php }} coverage: none @@ -37,8 +37,8 @@ jobs: name: PHP compatibility runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: shivammathur/setup-php@v2 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 with: php-version: '8.5' coverage: none @@ -74,8 +74,8 @@ jobs: WP_TESTS_DB_PASSWORD: root WP_TESTS_DB_NAME: wordpress_test steps: - - uses: actions/checkout@v4 - - uses: shivammathur/setup-php@v2 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 with: php-version: ${{ matrix.php }} extensions: mysqli @@ -90,8 +90,8 @@ jobs: name: Prettier runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 cache: npm @@ -108,13 +108,13 @@ jobs: name: Plugin Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - name: Build plugin package # Same file selection as the wordpress.org deployment (.distignore). run: | mkdir -p build/wirecore-rest-control rsync -a --exclude-from=.distignore ./ build/wirecore-rest-control/ --exclude=/build - - uses: wordpress/plugin-check-action@v1 + - uses: wordpress/plugin-check-action@10857da14b6c2246d15402b3e69f777edcf8c12e # v1.1.9 with: build-dir: build/wirecore-rest-control slug: wirecore-rest-control diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec2b668..68d1f6a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest environment: wordpress.org steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - name: Check version numbers run: | @@ -39,7 +39,7 @@ jobs: - name: Deploy to wordpress.org id: deploy - uses: 10up/action-wordpress-plugin-deploy@stable + uses: 10up/action-wordpress-plugin-deploy@54bd289b8525fd23a5c365ec369185f2966529c2 # 2.3.0 with: generate-zip: true env: @@ -49,7 +49,7 @@ jobs: ASSETS_DIR: .wordpress-org - name: Create GitHub release - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2 with: files: ${{ steps.deploy.outputs.zip-path }} generate_release_notes: true diff --git a/CLAUDE.md b/CLAUDE.md index a7d3eca..5533a1e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -49,4 +49,4 @@ Tests live in `tests/` (`test-*.php`, base class `WireCore_RC_TestCase`). They a ## Release -Bump `Version:` in `wirecore-rest-control.php` and `Stable tag:` in `readme.txt` together, and add the entry to the changelog in `readme.txt` and `CHANGELOG.md`. Pushing a tag like `1.0.1` (no `v`) runs `.github/workflows/release.yml`, which verifies the version numbers and deploys to the wordpress.org SVN repository. +Bump `Version:` in `wirecore-rest-control.php` and `Stable tag:` in `readme.txt` together, and add the entry to the changelog in `readme.txt` and `CHANGELOG.md`. Pushing a tag like `1.0.1` (no `v`) runs `.github/workflows/release.yml`, which verifies the version numbers and deploys to the wordpress.org SVN repository. Changes to `readme.txt` or `.wordpress-org/` alone reach wordpress.org through `.github/workflows/assets.yml` on `main`, no release needed. Actions are pinned to commit SHAs (comment with the version), Dependabot updates them. diff --git a/README.md b/README.md index ade50f6..05a19c3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,45 @@ -# WireCore REST Control - -Disable the WordPress REST API selectively – per namespace, route and HTTP method, including the routes of other plugins, with IP, role and user exceptions. +
+
+
+ Disable the WordPress REST API selectively – per namespace, route and HTTP method,
+ including the routes of other plugins, with IP, role and user exceptions.
+ WordPress 5.8+ · PHP 7.4 – 8.5 · English and German
+
+ wordpress.org · + Installation · + How it compares · + WP-CLI · + Development · + Changelog · + Security +
+ + + +## About Instead of an all-or-nothing switch, WireCore REST Control lists **every registered REST route** (core, themes and all plugins), shows which plugin or theme registered it, and lets you decide per namespace and per route who may read and who may write. The user-facing description lives in [`readme.txt`](readme.txt), which is also shown on wordpress.org. +## Why WireCore REST Control + +The REST API exposes more than most sites need: the user names of all authors (`/wp/v2/users`), and every route that any installed plugin registers – often without anyone having looked at it. Switching the whole API off for visitors is the usual answer, but it breaks the plugins that rely on it in the front end: contact forms, the WooCommerce checkout, embeds, statistics. + +WireCore REST Control closes everything by default and opens exactly what is needed – per route, per namespace, separately for reading and writing – with the front-end plugins that need the API allowed out of the box. + ## Features - Default rule plus overrides per namespace and route, separately for reading (GET/HEAD) and writing (POST/PUT/PATCH/DELETE). Rule levels: Public, Logged-in only (optionally limited to roles), Admins only, Blocked, Inherit. @@ -16,10 +50,31 @@ The user-facing description lives in [`readme.txt`](readme.txt), which is also s - Covers `_embed` and `/batch/v1` sub-requests; requests with invalid parameters are blocked before WordPress reveals the expected parameters. - Optional log of blocked requests (IP stored in full, shortened or not at all), self-test, JSON export/import, WP-CLI. - Multisite: settings per site, network activation supported. -- Translations: English source strings, German (`de_DE`, `de_DE_formal`) bundled. +- Translations: English source strings, German (`de_DE`, `de_DE_formal`) via translate.wordpress.org. Requires WordPress 5.8+ and PHP 7.4+. +## How it compares + +| | WireCore REST Control | [Disable REST API](https://wordpress.org/plugins/disable-json-api/) | [Disable WP REST API](https://wordpress.org/plugins/disable-wp-rest-api/) | [Perfmatters](https://perfmatters.io/docs/disable-wordpress-rest-api/) | [JWT Authentication for WP REST APIs](https://wordpress.org/plugins/wp-rest-api-authentication/) | +| ---------------------------------------------------------------------- | :-----------------------------------------------------------------------: | :-----------------------------------------------------------------: | :-----------------------------------------------------------------------: | :--------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------: | +| Blocks the REST API for logged-out visitors | ✓ | ✓ | ✓ | ✓ | ✓ | +| Allows individual routes, including those of other plugins | ✓ | ✓ | – | via code filter | core routes; others in premium | +| Allows whole namespaces | ✓ | ✓ | – | ? | ? | +| Rules per user role | ✓ | ✓ | – | admins only | premium | +| Separate rules for reading and writing | ✓ | ? | – | ? | ? | +| IP allow and deny lists | ✓ with CIDR ranges | ? | allow list in paid add-on | ? | ? | +| Front-end plugins keep working out of the box | ✓ Contact Form 7, WooCommerce Store API, oEmbed, LiteSpeed, WP Statistics | ? | – (manual guide for Contact Form 7) | ✓ Contact Form 7, LiteSpeed and others | ? | +| Custom error message and status code | ✓ | message via filter | message via filter; status in paid add-on | ? | ? | +| Shows which plugin registered a route, log of blocked requests, WP-CLI | ✓ | ? | – | ? | ? | +| Token authentication (JWT, OAuth, API keys) | – | – | – | – | ✓ its main purpose | +| Price | free | free | free; paid add-on REST Pro Tools | from $29.95/year | free; premium $499/year | +| Last update (tested up to WordPress) | November 2026 (7.1) | September 2023 (6.3) | August 2026 (7.1) | October 2026 | October 2026 (7.1) | + +As of 9 November 2026 – Disable REST API 1.8, Disable WP REST API 2.6.9, Perfmatters 2.6.9, JWT Authentication for WP REST APIs 5.0.0 – from each plugin's own documentation; `?` means it is not documented there. If something has changed, a correction is welcome. + +Where WireCore REST Control is behind today: it is new, while the others have run on tens of thousands of sites for years. It does not authenticate requests itself – for JWT, OAuth or API keys, use an authentication plugin alongside it, or WordPress' application passwords. It does not rename endpoints or fields like [WP REST API Controller](https://wordpress.org/plugins/wp-rest-api-controller/). And in a multisite the rules are set per site; there are no network-wide rules. + ## Installation From the WordPress plugin directory: _Plugins → Add New → "WireCore REST Control"_. @@ -147,7 +202,7 @@ Only the files needed by the plugin are shipped. Development files are excluded ## Releasing 1. Bump `Version:` in `wirecore-rest-control.php` and `Stable tag:` in `readme.txt`, and add the changelog entry to `readme.txt` and `CHANGELOG.md`. -2. Commit and push to `main`, wait for CI to pass. +2. Merge it into `main` via pull request (CI must pass). 3. Create and push a tag with the version number, without a `v` prefix: ```bash @@ -156,7 +211,9 @@ Only the files needed by the plugin are shipped. Development files are excluded [`.github/workflows/release.yml`](.github/workflows/release.yml) then checks that tag, plugin header and stable tag match, deploys the package (files selected by `.distignore`, assets from `.wordpress-org/`) to the wordpress.org SVN repository and creates a GitHub release with the ZIP. -One-time setup: add the secrets `SVN_USERNAME` and `SVN_PASSWORD` (the SVN password from the wordpress.org profile under _Account & Security_) to the GitHub environment `wordpress.org`. The very first version is submitted manually at [wordpress.org/plugins/developers/add](https://wordpress.org/plugins/developers/add/); the workflow takes over once the plugin has been approved. +Changes to `readme.txt` (e.g. "Tested up to") or `.wordpress-org/` alone don't need a release: [`.github/workflows/assets.yml`](.github/workflows/assets.yml) publishes them when they reach `main`, as long as the code on `main` matches the released version. It can also be started manually under _Actions_. + +One-time setup: add the secrets `SVN_USERNAME` and `SVN_PASSWORD` (the SVN password from the wordpress.org profile under _Account & Security_) to the GitHub environment `wordpress.org`, and allow the tag pattern `*.*.*` and the branch `main` under its deployment branches and tags. The very first version is submitted manually at [wordpress.org/plugins/developers/add](https://wordpress.org/plugins/developers/add/); the workflow takes over once the plugin has been approved. ## License