From a0dba36e67d00ca5c4996054b3c008ba15bca6b4 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Sep 2013 13:05:55 +0200 Subject: [PATCH 1/3] Enable navigator by default --- lib/classes/patch/370a3.class.php | 2 +- lib/conf.d/_GV_template.inc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/classes/patch/370a3.class.php b/lib/classes/patch/370a3.class.php index 6e10372396..04dd62628f 100644 --- a/lib/classes/patch/370a3.class.php +++ b/lib/classes/patch/370a3.class.php @@ -60,7 +60,7 @@ class patch_370a3 implements patchInterface } catch (\Exception_NotFound $e) { $client = \API_OAuth2_Application::create($appbox, null, \API_OAuth2_Application_Navigator::CLIENT_NAME); - $client->set_activated(false); + $client->set_activated(true); $client->set_grant_password(true); $client->set_website("http://www.phraseanet.com"); $client->set_client_id(\API_OAuth2_Application_Navigator::CLIENT_ID); diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index 01fb149613..dfe7a4f001 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -243,9 +243,9 @@ $GV = array( 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_client_navigator', 'comment' => _('reglages:: Authoriser l\'application smartphone *Phraseanet Navigator* à se connecter sur cette instance'), - 'default' => false, + 'default' => true, 'required' => true - ) + ), ) ), array( 'section' => _('GV::section:: Gestionnaire d\'evenements'), From 871fa40553edfea0f264ef3894a511ae03f9f65d Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Sep 2013 13:30:33 +0200 Subject: [PATCH 2/3] Add Office Plugin client id and secret --- lib/Alchemy/Phrasea/Application/Api.php | 5 ++ lib/Alchemy/Phrasea/Core/Version.php | 2 +- .../OAuth2/Application/OfficePlugin.class.php | 17 +++++ lib/classes/API/V1/adapter.class.php | 3 + lib/classes/patch/3715.class.php | 71 +++++++++++++++++++ lib/conf.d/_GV_template.inc | 7 ++ lib/conf.d/bases_structure.xml | 16 +++++ 7 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 lib/classes/API/OAuth2/Application/OfficePlugin.class.php create mode 100644 lib/classes/patch/3715.class.php diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index 6b40c37243..379bce8412 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -85,6 +85,11 @@ return call_user_func(function() { throw new \API_V1_exception_forbidden(_('The use of phraseanet Navigator is not allowed')); } + if ($oAuth2App->get_client_id() == \API_OAuth2_Application_OfficePlugin::CLIENT_ID + && ! $registry->get('GV_client_officeplugin')) { + throw new \API_V1_exception_forbidden('The use of Office Plugin is not allowed.'); + } + if ($session->is_authenticated()) { $app['dispatcher']->dispatch(PhraseaEvents::API_OAUTH2_END, new ApiOAuth2EndEvent()); return; diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index d21d11cff5..9f29a5c00b 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core; */ class Version { - protected static $number = '3.7.14'; + protected static $number = '3.7.15'; protected static $name = 'Carnosaurus'; public static function getNumber() diff --git a/lib/classes/API/OAuth2/Application/OfficePlugin.class.php b/lib/classes/API/OAuth2/Application/OfficePlugin.class.php new file mode 100644 index 0000000000..dbdcfe2cd4 --- /dev/null +++ b/lib/classes/API/OAuth2/Application/OfficePlugin.class.php @@ -0,0 +1,17 @@ + array( 'active' => $registry->get('GV_client_navigator'), ), + 'office-plugin' => array( + 'active' => $registry->get('GV_client_navigator'), + ), 'homepage' => array( 'viewType' => $registry->get('GV_home_publi'), ), diff --git a/lib/classes/patch/3715.class.php b/lib/classes/patch/3715.class.php new file mode 100644 index 0000000000..bce474913a --- /dev/null +++ b/lib/classes/patch/3715.class.php @@ -0,0 +1,71 @@ +release; + } + + public function require_all_upgrades() + { + return false; + } + + /** + * + * @return Array + */ + public function concern() + { + return $this->concern; + } + + /** + * @param base $databox + */ + public function apply(base &$appbox) + { + $appbox = \appbox::get_instance(\bootstrap::getCore()); + + try { + \API_OAuth2_Application::load_from_client_id($appbox, \API_OAuth2_Application_OfficePlugin::CLIENT_ID); + } catch (\Exception_NotFound $e) { + $client = \API_OAuth2_Application::create($appbox, null, \API_OAuth2_Application_OfficePlugin::CLIENT_NAME); + + $client->set_activated(true); + $client->set_grant_password(true); + $client->set_website("http://www.phraseanet.com"); + $client->set_client_id(\API_OAuth2_Application_OfficePlugin::CLIENT_ID); + $client->set_client_secret(\API_OAuth2_Application_OfficePlugin::CLIENT_SECRET); + $client->set_type(\API_OAuth2_Application::DESKTOP_TYPE); + $client->set_redirect_uri(\API_OAuth2_Application::NATIVE_APP_REDIRECT_URI); + } + + return true; + } +} diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index dfe7a4f001..c5b33e0520 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -246,6 +246,13 @@ $GV = array( 'default' => true, 'required' => true ), + array( + 'type' => \registry::TYPE_BOOLEAN, + 'name' => 'GV_client_officeplugin', + 'comment' => _('Authorize Microsoft Office Plugin to connect.'), + 'default' => true, + 'required' => true + ), ) ), array( 'section' => _('GV::section:: Gestionnaire d\'evenements'), diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index 46f6015c95..2aa1517823 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -387,6 +387,22 @@ 1 1 + + null + null + desktop + office-plugin + + http://www.phraseanet.com + NOW() + NOW() + \alchemy\phraseanet\id\999585175b5fbb6e140efbdfea86c561 + \alchemy\phraseanet\secret\6d53d0bc74e6c8c1a325541f71da1ea5 + AfCF61 + urn:ietf:wg:oauth:2.0:oob + 1 + 1 + InnoDB From 3649d89b81e2edbd055ca1ea8b030c470de7155e Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 9 Sep 2013 13:30:46 +0200 Subject: [PATCH 3/3] Cleanup CS --- lib/classes/API/OAuth2/Application/Navigator.class.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/classes/API/OAuth2/Application/Navigator.class.php b/lib/classes/API/OAuth2/Application/Navigator.class.php index 934761511f..c91f7b4741 100644 --- a/lib/classes/API/OAuth2/Application/Navigator.class.php +++ b/lib/classes/API/OAuth2/Application/Navigator.class.php @@ -9,12 +9,6 @@ * file that was distributed with this source code. */ -/** - * - * @license http://opensource.org/licenses/gpl-3.0 GPLv3 - * @link www.phraseanet.com - */ - class API_OAuth2_Application_Navigator { const CLIENT_ID = '\alchemy\phraseanet\id\4f981093aebb66.06844599';