Title: Disable REST API and Require JWT / OAuth Authentication
Author: Benjamin Intal
Published: <strong>سبتمبر 26, 2017</strong>
Last modified: سبتمبر 26, 2017

---

Search plugins

![](https://ps.w.org/disable-rest-api-and-require-jwt-oauth-authentication/assets/
banner-772x250.png?rev=1736141)

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://ps.w.org/disable-rest-api-and-require-jwt-oauth-authentication/assets/
icon-256x256.png?rev=1736141)

# Disable REST API and Require JWT / OAuth Authentication

 By [Benjamin Intal](https://profiles.wordpress.org/bfintal/)

[Download](https://downloads.wordpress.org/plugin/disable-rest-api-and-require-jwt-oauth-authentication.1.0.zip)

 * [Details](https://arq.wordpress.org/plugins/disable-rest-api-and-require-jwt-oauth-authentication/#description)
 * [Reviews](https://arq.wordpress.org/plugins/disable-rest-api-and-require-jwt-oauth-authentication/#reviews)
 *  [Installation](https://arq.wordpress.org/plugins/disable-rest-api-and-require-jwt-oauth-authentication/#installation)
 * [Development](https://arq.wordpress.org/plugins/disable-rest-api-and-require-jwt-oauth-authentication/#developers)

 [Support](https://wordpress.org/support/plugin/disable-rest-api-and-require-jwt-oauth-authentication/)

## Description

**When you activate this plugin, all REST API endpoints will be disabled for non-
authorized requests.**

Best used with any of these plugins:

 * [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
 * [WP OAuth Server](https://wordpress.org/plugins/oauth2-provider/)

Blocks _ALL_ REST API endpoints except for:

 * /jwt-auth/v1/token/validate
 * /jwt-auth/v1/token
 * /oauth/authorize
 * /oauth/token
 * /oauth/me

Allows all REST API endpoints if they come with a valid **Bearer Token Authentication**(
authentication via GET URL variables are still blocked)

When used alone in your site, your REST API will essentially be disabled.

> Note that this plugin itself doesn’t provide JWT or OAuth authentication, it only
> whitelists them.

#### Features

 * No settings page
 * You can whitelist other REST API endpoint via a filter hook (see FAQs below)
 * Blocks all REST API endpoints.. but
 * Allows requests with Bearer Token Authentication.. and
 * Allows [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)&
   [WP OAuth Server](https://wordpress.org/plugins/oauth2-provider/) authentication
   endpoints

## Screenshots

[⌊Blocked REST API requests⌉⌊Blocked REST API requests⌉[

Blocked REST API requests

[⌊Authenticated REST API requests are allowed⌉⌊Authenticated REST API requests are
allowed⌉[

Authenticated REST API requests are allowed

## Installation

 1. Head over to Plugins > Add New in the admin
 2. Search for “Disable REST API and Require Authentication”
 3. Install & activate the plugin
 4. Now your REST API endpoints are disabled for non-authenticated requests.

## FAQ

  Installation Instructions

 1. Head over to Plugins > Add New in the admin
 2. Search for “Disable REST API and Require Authentication”
 3. Install & activate the plugin
 4. Now your REST API endpoints are disabled for non-authenticated requests.

  How is this different from Disable REST API?

This plugin is similar to Disable REST API, wherein it disables all REST API endpoints,
_but it_ still allows the authentication endpoints provided by:

 * [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
 * [WP OAuth Server](https://wordpress.org/plugins/oauth2-provider/)

And if a **Bearer Token Authentication** is provided, then the REST API becomes 
available.

  How can I check if my REST API is disabled?

Open a new incognito browser tab or private browser tab and visit your `wp-json`
URL:

> `http://mysite/wp-json/`

You will see this message:

> `{"code":"rest_not_logged_in","message":"You are not currently logged in.","data":{"
> status":401}}`

  What is a Bearer Token Authenticated REST API request?

A Bearer Token Authenticated REST API request is a REST API call with this **header**:

> Authorization: Bearer XXXXXXX

The _XXXXXXX_ corresponds to the authentication token given by any of these 2 plugins:

 * [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
 * [WP OAuth Server](https://wordpress.org/plugins/oauth2-provider/)

  How do I implement JWT / OAuth authentication?

That is outside the scope of this plugin, please refer to the docs of the respective
plugins:

 * [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
 * [WP OAuth Server](https://wordpress.org/plugins/oauth2-provider/)

  How do I whitelist other REST API endpoints? (via filter hook)

I’ve placed a filter called `reqauth/allowed_endpoints` where you can add your own
REST API endpoints to the whitelist.

For example, I want to allow `/my-endpoint` for non-authorized REST API calls:

    ```
    add_filter( 'reqauth/allowed_endpoints', 'allow_my_endpoints' );
    function( $allowed_endpoints ) {
        $allowed_endpoints[] = '/my-endpoint';
        return $allowed_endpoints;
    }
    ```

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“Disable REST API and Require JWT / OAuth Authentication” is open source software.
The following people have contributed to this plugin.

Contributors

 *   [ Benjamin Intal ](https://profiles.wordpress.org/bfintal/)
 *   [ gambitph ](https://profiles.wordpress.org/gambitph/)

[Translate “Disable REST API and Require JWT / OAuth Authentication” into your language.](https://translate.wordpress.org/projects/wp-plugins/disable-rest-api-and-require-jwt-oauth-authentication)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/disable-rest-api-and-require-jwt-oauth-authentication/),
check out the [SVN repository](https://plugins.svn.wordpress.org/disable-rest-api-and-require-jwt-oauth-authentication/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/disable-rest-api-and-require-jwt-oauth-authentication/)
by [RSS](https://plugins.trac.wordpress.org/log/disable-rest-api-and-require-jwt-oauth-authentication/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### v1.0

 * Initial release

## Meta

 *  Version **1.0**
 *  Last updated **9 years ago**
 *  Active installations **50+**
 *  WordPress version ** 4.4 or higher **
 *  Tested up to **4.8.34**
 *  PHP version ** 5.2 or higher **
 *  Language
 * [English (US)](https://wordpress.org/plugins/disable-rest-api-and-require-jwt-oauth-authentication/)
 * Tags
 * [api](https://arq.wordpress.org/plugins/tags/api/)[JSON](https://arq.wordpress.org/plugins/tags/json/)
   [rest](https://arq.wordpress.org/plugins/tags/rest/)[rest-api](https://arq.wordpress.org/plugins/tags/rest-api/)
   [web](https://arq.wordpress.org/plugins/tags/web/)
 *  [Advanced View](https://arq.wordpress.org/plugins/disable-rest-api-and-require-jwt-oauth-authentication/advanced/)

## Ratings

No reviews have been submitted yet.

[Your review](https://wordpress.org/support/plugin/disable-rest-api-and-require-jwt-oauth-authentication/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/disable-rest-api-and-require-jwt-oauth-authentication/reviews/)

## Contributors

 *   [ Benjamin Intal ](https://profiles.wordpress.org/bfintal/)
 *   [ gambitph ](https://profiles.wordpress.org/gambitph/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/disable-rest-api-and-require-jwt-oauth-authentication/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5A97UAY68JHY4)