Wordfence Central Requirement For Unauthenticated REST API
-
I have many WordPress sites connected to Wordfence Central and all work fine. I want to disable the WordPress REST API to unauthenticated requests as an enhanced security measure.
To achieve this I use the following code:
add_filter( 'rest_authentication_errors', function( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error(
'rest_disabled',
__( 'The WordPress REST API has been disabled on this site.' ),
array( 'status' => rest_authorization_required_code() ) );
}
return $result;
});With the code enabled, the WordPress REST API is available to authenticated users but is unavailable to unauthenticated users.
View post on imgur.com
Additionally, with this code enabled, the connection between my WordPress site and Wordfence Central is immediately broken:
View post on imgur.com
It surprises me that, in order to function correctly, Wordfence Central needs to make unauthenticated requests to my site’s REST API.
Please help me to understand:
– Why does Wordfence Central require unauthenticated access to my site’s REST API?
– How can such a requirement be a ‘best practice’ secure implementation?
– How does this relate to the onboarding process (‘Connect site to Wordfence Central’) where there is mention of sharing PKI keys?David.
- The topic ‘Wordfence Central Requirement For Unauthenticated REST API’ is closed to new replies.