內容簡介
JSON REST API 和 XML-RPC API 是與 WordPress 遠程交互的強大方式。
如果您沒有需要使用 JSON REST API 或 XML-RPC API 與外部應用程序通信的需求,您應禁用對外部請求的訪問。
在標準的 WordPress 安裝中,JSON REST API 和 XML-RPC API 預設啟用。
特別是,REST API 也開啟了未登錄用戶的訪問權限。這意味著您的 WordPress 可能會洩漏數據,例如任何人都可以:
使用 REST API(而不是網絡爬蟲)輕鬆複製您的已發布內容;
獲取所有用戶的列表(包括他們的 ID、暱稱和名字);
檢索您不想公開的其他信息(如未公開網頁或尚未使用的保存媒體)。
即使您可以通過編寫自己的代碼使用原生過濾器來完成這些操作,此外掛旨在通過管理面板或簡單的 API 過濾器來幫助您控制 JSON REST API 和 XML-RPC API 的訪問權限。
基本功能
禁止未登錄用戶使用 REST API 介面。
禁用 REST API 中的 JSONP 支持。
對 REST API 添加基本認證。
刪除 REST 的 <link> 標籤、REST Link HTTP 標頭和 REST Really Simple Discovery (RSD) 資訊。
設置信任的用戶、IP/網絡和端點以供未登錄用戶的 REST 請求使用。
更改 REST 端點前綴。
禁用 XML-RPC API 介面。
刪除 Really Simple Discovery (RDS) 資訊的 <link>。
刪除 X-Pingback HTTP 標頭。
設置信任的用戶、IP/網絡和方法以供 XML-RPC 請求使用。
在用戶列表管理屏幕中顯示用戶的訪問資訊。
使用方法
安裝插件後,您可以使用以下方式控制設置:
使用「設置」 > 「REST XML-RPC 數據檢查器」管理屏幕。
以編程方式使用 rest_xmlrpc_data_checker_settings 過濾器(請參閱下文)。
API
鉤子 Hooks
rest_xmlrpc_data_checker_settings
過濾插件設置值。
apply_filters( 'rest_xmlrpc_data_checker_settings', array $settings )
rest_xmlrpc_data_checker_admin_settings
過濾器允許在管理中顯示或隱藏插件設置頁面。
apply_filters( 'rest_xmlrpc_data_checker_admin_settings', boolean $display )
rest_xmlrpc_data_checker_rest_error
在插件檢查之後過濾 JSON REST 認證錯誤。
apply_filters( 'rest_xmlrpc_data_checker_rest_error', WP_Error|boolean $result )
xmlrpc_before_insert_post
在將帖子通過 XML-RPC 插入數據庫之前,過濾 XML-RPC 帖子數據。
apply_filters( 'xmlrpc_before_insert_post', array|IXR_Error $content_struct, WP_User $user )
外掛標籤
開發者團隊
原文外掛簡介
JSON REST API and XML-RPC API are powerful ways to remotely interact with WordPress.
If you don’t have external applications that need to communicate with your WordPress instance using JSON REST API or XML-RPC API you should disable access to them for external requests.
In the standard WordPress installation JSON REST API and XML-RPC API are enabled by default.
In particular the REST API is turned on also for unlogged users. This means that your WordPress instance is potentially leaking data, for example anyone could be able to:
copy easily your published contents natively with the REST API (and not with a web crawler);
get the list of all users (with their ID, nickname and name);
retrieve other information that you didn’t want to be public (such as an unlisted published page or a saved media not yet used).
Even if you could do the stuff by writing your own code using native filters, this plugin aims to help you to control JSON REST API and XML-RPC API accesses from the administration panel or programmatically by a simple API filter.
Basic Features
Disable REST API interface for unlogged users.
Disable JSONP support on REST API.
Add Basic Authentication to REST API.
Remove REST tags, REST Link HTTP header and REST Really Simple Discovery (RSD) informations.
Setup trusted users, IP/Networks and endpoints for unlogged users REST requests.
Change REST endpoint prefix.
Disable XML-RPC API interface.
Remove to the Really Simple Discovery (RDS) informations.
Remove X-Pingback HTTP header.
Setup trusted users, IP/Networks and methods for XML-RPC requests.
Show user’s access informations in users list administration screen.
Usage
Once the plugin is installed you can control settings in the following ways:
Using the Settings->REST XML-RPC Data Checker administration screen.
Programmatically, by using rest_xmlrpc_data_checker_settings filter (see below).
API
Hooks
rest_xmlrpc_data_checker_settings
Filters plugin settings values.
apply_filters( 'rest_xmlrpc_data_checker_settings', array $settings )
rest_xmlrpc_data_checker_admin_settings
Filter allowing to display or not the plugin settings page in the administration.
apply_filters( 'rest_xmlrpc_data_checker_admin_settings', boolean $display )
rest_xmlrpc_data_checker_rest_error
Filter JSON REST authentication error after plugin checks.
apply_filters( 'rest_xmlrpc_data_checker_rest_error', WP_Error|boolean $result )
xmlrpc_before_insert_post
Filter XML-RPC post data to be inserted via XML-RPC before to insert post into database.
apply_filters( 'xmlrpc_before_insert_post', array|IXR_Error $content_struct, WP_User $user )
