Created
January 20, 2023 00:37
-
-
Save karlazz/31ae51d34277a27077437e9155c830dd to your computer and use it in GitHub Desktop.
unset API endpoints example: user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unset user API endpoints to prevent user enumeration | |
add_filter('rest_endpoints', function($endpoints) { | |
unset( $endpoints['/wp/v2/users'] ); | |
unset( $endpoints ['/wp/v2/users/(?P<id>[\d]+)']); | |
unset( $endpoints ['[/wp/v2/users/me]']); | |
unset( $endpoints ['[/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords]']); | |
unset( $endpoints ['[/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords/introspect]']); | |
unset( $endpoints ['[/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords/(?P<uuid>[\w\-]+)']); | |
return $endpoints; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment