Download the PHP package alleyinteractive/wp-rest-api-guard without Composer
On this page you can find all versions of the php package alleyinteractive/wp-rest-api-guard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alleyinteractive/wp-rest-api-guard
More information about alleyinteractive/wp-rest-api-guard
Files in alleyinteractive/wp-rest-api-guard
Package wp-rest-api-guard
Short Description Restrict and control access to the REST API
License GPL-2.0-or-later
Homepage https://github.com/alleyinteractive/wp-rest-api-guard
Informations about the package wp-rest-api-guard
REST API Guard
Stable tag: 1.3.2
Requires at least: 6.0
Tested up to: 6.0
Requires PHP: 8.0
License: GPL v2 or later
Tags: alleyinteractive, rest-api-guard
Contributors: sean212
Restrict and control access to the REST API.
Installation
You can install the package via composer:
Usage
The WordPress REST API is generally very public and can share a good deal of information with the internet anonymously. This plugin aims to make it easier to restrict access to the REST API for your WordPress site.
Out of the box the plugin can:
- Disable anonymous access to the REST API.
- Restrict and control anonymous access to the REST API by namespace, path, etc.
Settings Page
The plugin can be configured via the Settings page (Settings -> REST API Guard
) or via the relevant filter.
Preventing Access to User Information (wp/v2/users
)
By default, the plugin will restrict anonymous access to the users endpoint. This can be prevented in the plugin's settings or via code:
Preventing Access to Index (/
) or Namespace Endpoints (wp/v2
)
To prevent anonymous users from browsing your site and discovering what plugins/post types are set up, the plugin restricts access to the index (/
) and namespace (wp/v2
) endpoints. This can be prevented in the plugin's settings or via code:
Restrict Anonymous Access to the REST API
The plugin can restrict anonymous access for any request to the REST API in the plugin's settings or via code:
Limit Anonymous Access to Specific Namespaces/Routes (Allowlist)
Anonymous users can be granted access only to specific namespaces/routes. Requests outside of these paths will be denied. This can be configured in the plugin's settings or via code:
Restrict Anonymous Access to Specific Namespaces/Routes (Denylist)
Anonymous users can be restricted from specific namespaces/routes. This acts as a denylist for specific paths that an anonymous user cannot access. The paths support regular expressions for matching. The use of the Allowlist takes priority over this denylist. This can be configured in the plugin's settings or via code:
Require JSON Web Token (JWT) Authentication for Anonymous Users
Anonymous users can be required to authenticate via a JSON Web Token (JWT) to
access the REST API. Users should pass an Authorization: Bearer <token>
header
with their request. This can be configured in the plugin's settings or via code:
Out of the box, the plugin will look for a JWT in the `Authorization: Bearer