mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
1
Makefile
1
Makefile
@@ -18,6 +18,7 @@ clean_assets:
|
|||||||
rm -rf ./node_modules
|
rm -rf ./node_modules
|
||||||
rm -rf ./www/assets
|
rm -rf ./www/assets
|
||||||
rm -rf ./www/bower_components
|
rm -rf ./www/bower_components
|
||||||
|
touch ./node_modules/.gitkeep
|
||||||
|
|
||||||
config:
|
config:
|
||||||
@php bin/console compile:configuration
|
@php bin/console compile:configuration
|
||||||
|
@@ -7,7 +7,6 @@ main:
|
|||||||
languages: []
|
languages: []
|
||||||
key: ''
|
key: ''
|
||||||
api_require_ssl: true
|
api_require_ssl: true
|
||||||
api_disabled: true
|
|
||||||
database:
|
database:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 3306
|
port: 3306
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
namespace Alchemy\Phrasea\Controller\Admin;
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\Configuration;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
||||||
use Alchemy\Phrasea\Core\Configuration\RegistryManipulator;
|
use Alchemy\Phrasea\Core\Configuration\RegistryManipulator;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
@@ -20,12 +22,15 @@ class SetupController extends Controller
|
|||||||
{
|
{
|
||||||
/** @var RegistryManipulator $manipulator */
|
/** @var RegistryManipulator $manipulator */
|
||||||
$manipulator = $this->app['registry.manipulator'];
|
$manipulator = $this->app['registry.manipulator'];
|
||||||
|
/** @var PropertyAccess $config */
|
||||||
|
$config = $this->app['conf'];
|
||||||
|
|
||||||
$form = $manipulator->createForm($this->app['conf']);
|
$form = $manipulator->createForm($this->app['conf']);
|
||||||
|
|
||||||
if ('POST' === $request->getMethod()) {
|
if ('POST' === $request->getMethod()) {
|
||||||
$form->submit($request->request->all());
|
$form->submit($request->request->all());
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$this->app['conf']->set('registry', $manipulator->getRegistryData($form));
|
$config->set('registry', $manipulator->getRegistryData($form));
|
||||||
|
|
||||||
return $this->app->redirectPath('setup_display_globals');
|
return $this->app->redirectPath('setup_display_globals');
|
||||||
}
|
}
|
||||||
|
18
lib/Alchemy/Phrasea/ControllerProvider/Api/Api.php
Normal file
18
lib/Alchemy/Phrasea/ControllerProvider/Api/Api.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\ControllerProvider\Api;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
||||||
|
use Silex\Application;
|
||||||
|
|
||||||
|
abstract class Api
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function isApiEnabled(Application $application)
|
||||||
|
{
|
||||||
|
/** @var PropertyAccess $config */
|
||||||
|
$config = $application['conf'];
|
||||||
|
|
||||||
|
return $config->get([ 'registry', 'api-clients', 'api-enabled' ], true) == true;
|
||||||
|
}
|
||||||
|
}
|
@@ -13,12 +13,13 @@ 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;
|
||||||
use Silex\ServiceProviderInterface;
|
use Silex\ServiceProviderInterface;
|
||||||
|
|
||||||
class OAuth2 implements ControllerProviderInterface, ServiceProviderInterface
|
class OAuth2 extends Api implements ControllerProviderInterface, ServiceProviderInterface
|
||||||
{
|
{
|
||||||
public function register(Application $app)
|
public function register(Application $app)
|
||||||
{
|
{
|
||||||
@@ -34,6 +35,10 @@ class OAuth2 implements ControllerProviderInterface, ServiceProviderInterface
|
|||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
|
if (! $this->isApiEnabled($app)) {
|
||||||
|
return $app['controllers_factory'];
|
||||||
|
}
|
||||||
|
|
||||||
/** @var ControllerCollection $controllers */
|
/** @var ControllerCollection $controllers */
|
||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
|
@@ -14,13 +14,14 @@ 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;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ServiceProviderInterface;
|
use Silex\ServiceProviderInterface;
|
||||||
|
|
||||||
class V1 implements ControllerProviderInterface, ServiceProviderInterface
|
class V1 extends Api implements ControllerProviderInterface, ServiceProviderInterface
|
||||||
{
|
{
|
||||||
const VERSION = '1.5.0';
|
const VERSION = '1.5.0';
|
||||||
|
|
||||||
@@ -46,6 +47,10 @@ class V1 implements ControllerProviderInterface, ServiceProviderInterface
|
|||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
|
if (! $this->isApiEnabled($app)) {
|
||||||
|
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;
|
||||||
@@ -22,7 +23,7 @@ use Silex\Controller;
|
|||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ServiceProviderInterface;
|
use Silex\ServiceProviderInterface;
|
||||||
|
|
||||||
class V2 implements ControllerProviderInterface, ServiceProviderInterface
|
class V2 extends Api implements ControllerProviderInterface, ServiceProviderInterface
|
||||||
{
|
{
|
||||||
use ControllerProviderTrait;
|
use ControllerProviderTrait;
|
||||||
|
|
||||||
@@ -69,6 +70,10 @@ class V2 implements ControllerProviderInterface, ServiceProviderInterface
|
|||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
|
if (! $this->isApiEnabled($app)) {
|
||||||
|
return $app['controllers_factory'];
|
||||||
|
}
|
||||||
|
|
||||||
$controllers = $this->createCollection($app);
|
$controllers = $this->createCollection($app);
|
||||||
|
|
||||||
$controllers->before(new OAuthListener());
|
$controllers->before(new OAuthListener());
|
||||||
|
@@ -19,10 +19,26 @@ use Symfony\Component\Translation\TranslatorInterface;
|
|||||||
|
|
||||||
class RegistryManipulator
|
class RegistryManipulator
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var FormFactoryInterface
|
||||||
|
*/
|
||||||
private $factory;
|
private $factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
private $languages;
|
private $languages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
private $translator;
|
private $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param FormFactoryInterface $factory
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
|
* @param array $languages
|
||||||
|
*/
|
||||||
public function __construct(FormFactoryInterface $factory, TranslatorInterface $translator, array $languages)
|
public function __construct(FormFactoryInterface $factory, TranslatorInterface $translator, array $languages)
|
||||||
{
|
{
|
||||||
$this->factory = $factory;
|
$this->factory = $factory;
|
||||||
@@ -128,6 +144,7 @@ class RegistryManipulator
|
|||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
],
|
],
|
||||||
'api-clients' => [
|
'api-clients' => [
|
||||||
|
'api-enabled' => true,
|
||||||
'navigator-enabled' => true,
|
'navigator-enabled' => true,
|
||||||
'office-enabled' => true,
|
'office-enabled' => true,
|
||||||
],
|
],
|
||||||
|
@@ -18,6 +18,11 @@ class APIClientsFormType extends AbstractType
|
|||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
|
$builder->add('api-enabled', 'checkbox', [
|
||||||
|
'label' => 'Enable Phraseanet Web API',
|
||||||
|
'help_message' => 'The Phraseanet Web API allows other web application to rely on this instance'
|
||||||
|
]);
|
||||||
|
|
||||||
$builder->add('navigator-enabled', 'checkbox', [
|
$builder->add('navigator-enabled', 'checkbox', [
|
||||||
'label' => 'Authorize *Phraseanet Navigator*',
|
'label' => 'Authorize *Phraseanet Navigator*',
|
||||||
'help_message' => '*Phraseanet Navigator* is a smartphone application that allow user to connect on this instance',
|
'help_message' => '*Phraseanet Navigator* is a smartphone application that allow user to connect on this instance',
|
||||||
|
@@ -6,7 +6,6 @@ main:
|
|||||||
maintenance: false
|
maintenance: false
|
||||||
key: ''
|
key: ''
|
||||||
api_require_ssl: true
|
api_require_ssl: true
|
||||||
api_disabled: true
|
|
||||||
database:
|
database:
|
||||||
host: 'sql-host'
|
host: 'sql-host'
|
||||||
port: 3306
|
port: 3306
|
||||||
|
@@ -48,7 +48,7 @@
|
|||||||
chdir: /vagrant/
|
chdir: /vagrant/
|
||||||
|
|
||||||
- name: Enable API routes
|
- name: Enable API routes
|
||||||
shell: bin/setup system:config set main.api_disabled false
|
shell: bin/setup system:config set registry.api-clients.api-enable true
|
||||||
args:
|
args:
|
||||||
chdir: /vagrant/
|
chdir: /vagrant/
|
||||||
|
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
# Autodetect text files
|
|
||||||
* text=auto
|
|
||||||
|
|
||||||
# Force the following filetypes to have unix eols, so Windows does not break them
|
|
||||||
*.pp text eol=lf
|
|
||||||
*.sh text eol=lf
|
|
||||||
*.yaml text eol=lf
|
|
||||||
Puppetfile text eol=lf
|
|
||||||
.bash_aliases text eol=lf
|
|
||||||
.vimrc text eol=lf
|
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<form class="form-horizontal" id="GV_form_head">
|
<form class="form-horizontal" id="GV_form_head">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">Adresse : </label>
|
<label class="control-label">Adress : </label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="input-xxlarge" readonly="readonly" value="{{ app['conf'].get('servername') }}" />
|
<input type="text" class="input-xxlarge" readonly="readonly" value="{{ app['conf'].get('servername') }}" />
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user