From 490e35598dfa406d9acd886b85e3ae7e9260e27e Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 16 May 2019 14:36:45 +1000 Subject: [PATCH] Add rest.php (REST API endpoint) with feature flag Change-Id: I0f9aaa9cc81f93c00f7a28041615d7290b453803 --- includes/DefaultSettings.php | 7 +++++++ includes/Rest/EntryPoint.php | 6 ++++++ rest.php | 28 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 rest.php diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index a32af365d0..ce53060fba 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -8299,6 +8299,13 @@ $wgCrossSiteAJAXdomains = []; */ $wgCrossSiteAJAXdomainExceptions = []; +/** + * Enable the experimental REST API. + * + * This will be removed once the REST API is stable and used by clients. + */ +$wgEnableRestAPI = false; + /** @} */ # End AJAX and API } /************************************************************************//** diff --git a/includes/Rest/EntryPoint.php b/includes/Rest/EntryPoint.php index 40d0b4a2f8..a14c1a1294 100644 --- a/includes/Rest/EntryPoint.php +++ b/includes/Rest/EntryPoint.php @@ -32,6 +32,12 @@ class EntryPoint { $services = MediaWikiServices::getInstance(); $conf = $services->getMainConfig(); + if ( !$conf->get( 'EnableRestAPI' ) ) { + wfHttpError( 403, 'Access Denied', + 'Set $wgEnableRestAPI to true to enable the experimental REST API' ); + return; + } + $request = new RequestFromGlobals( [ 'cookiePrefix' => $conf->get( 'CookiePrefix' ) ] ); diff --git a/rest.php b/rest.php new file mode 100644 index 0000000000..3ac532e43d --- /dev/null +++ b/rest.php @@ -0,0 +1,28 @@ +