mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Add option to disable API via configuration setting
This commit is contained in:
@@ -6,6 +6,7 @@ main:
|
|||||||
maintenance: false
|
maintenance: false
|
||||||
languages: []
|
languages: []
|
||||||
key: ''
|
key: ''
|
||||||
|
api_disable: false
|
||||||
api_require_ssl: true
|
api_require_ssl: true
|
||||||
api_disabled: true
|
api_disabled: true
|
||||||
database:
|
database:
|
||||||
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\ControllerProvider\Api;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||||
use Alchemy\Phrasea\Controller\Api\OAuth2Controller;
|
use Alchemy\Phrasea\Controller\Api\OAuth2Controller;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
@@ -34,6 +35,13 @@ class OAuth2 implements ControllerProviderInterface, ServiceProviderInterface
|
|||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
|
/** @var PropertyAccess $config */
|
||||||
|
$config = $app['conf'];
|
||||||
|
|
||||||
|
if ($config->get('api_disable', false) == true) {
|
||||||
|
return $app['controllers_factory'];
|
||||||
|
}
|
||||||
|
|
||||||
/** @var ControllerCollection $controllers */
|
/** @var ControllerCollection $controllers */
|
||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\ControllerProvider\Api;
|
|||||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||||
use Alchemy\Phrasea\Controller\Api\V1Controller;
|
use Alchemy\Phrasea\Controller\Api\V1Controller;
|
||||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
||||||
use Alchemy\Phrasea\Core\Event\Listener\OAuthListener;
|
use Alchemy\Phrasea\Core\Event\Listener\OAuthListener;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
@@ -46,6 +47,13 @@ class V1 implements ControllerProviderInterface, ServiceProviderInterface
|
|||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
|
/** @var PropertyAccess $config */
|
||||||
|
$config = $app['conf'];
|
||||||
|
|
||||||
|
if ($config->get('api_disable', false) == true) {
|
||||||
|
return $app['controllers_factory'];
|
||||||
|
}
|
||||||
|
|
||||||
/** @var ControllerCollection $controllers */
|
/** @var ControllerCollection $controllers */
|
||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Controller\Api\LazaretController;
|
|||||||
use Alchemy\Phrasea\Controller\Api\SearchController;
|
use Alchemy\Phrasea\Controller\Api\SearchController;
|
||||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||||
use Alchemy\Phrasea\ControllerProvider\ControllerProviderTrait;
|
use Alchemy\Phrasea\ControllerProvider\ControllerProviderTrait;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
||||||
use Alchemy\Phrasea\Core\Event\Listener\OAuthListener;
|
use Alchemy\Phrasea\Core\Event\Listener\OAuthListener;
|
||||||
use Alchemy\Phrasea\Order\Controller\ApiOrderController;
|
use Alchemy\Phrasea\Order\Controller\ApiOrderController;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
@@ -70,6 +71,13 @@ class V2 implements ControllerProviderInterface, ServiceProviderInterface
|
|||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
|
/** @var PropertyAccess $config */
|
||||||
|
$config = $app['conf'];
|
||||||
|
|
||||||
|
if ($config->get('api_disable', false) == true) {
|
||||||
|
return $app['controllers_factory'];
|
||||||
|
}
|
||||||
|
|
||||||
$controllers = $this->createCollection($app);
|
$controllers = $this->createCollection($app);
|
||||||
|
|
||||||
$controllers->before(new OAuthListener());
|
$controllers->before(new OAuthListener());
|
||||||
|
Reference in New Issue
Block a user