Skip to content
Snippets Groups Projects
Commit 31cd6baf authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'dev#115382_artips_casv3_fix' into 'master'

Dev#115382 artips casv3 fix

See merge request !4246
parents 2c8ed44c fafaff8a
Branches
Tags
2 merge requests!4250Master,!4246Dev#115382 artips casv3 fix
Pipeline #15001 passed with stage
in 26 minutes and 39 seconds
Showing
with 435 additions and 10 deletions
'115382' =>
['Label' => this->_('Connecteur Artips')
'Desc' => $this->_('Artips propose des anecdotes à propos d\'œuvres d\'art'),
'Image' => '',
'Video' => '',
'Category' => 'Connecteurs',
'Right' => function($feature_description, $user) {return true;},
'Wiki' => 'https://wiki.bokeh-library-portal.org/index.php?title=Artips',
'Test' => '',
'Date' => '2021-07-01'],
\ No newline at end of file
- ticket #115382 : Ressource numérique: ajout d'un connecteur Artips.
\ No newline at end of file
......@@ -176,6 +176,7 @@ class AuthController extends ZendAfi_Controller_Action {
});
$service = $this->_getParam('service', '');
$cas = $this->_getParam('cas');
$url_action = $this->view->url(($form_action = $strategy->getFormAction($this->view->id_module))
? $form_action
......@@ -184,9 +185,10 @@ class AuthController extends ZendAfi_Controller_Action {
'id_module' => $this->view->id_module]);
$datas = $this->_getInspector()
->addToParams(['redirect_url' => $redirect,
'service' => $service,
'id_notice' => $this->view->id_notice]);
->addToParams(array_filter(['redirect_url' => $redirect,
'service' => $service,
'cas' => $cas,
'id_notice' => $this->view->id_notice]));
$settings = array_merge(['Preferences' => $preferences],
['FormOptions' => ['data' => array_merge($preferences, $datas),
......
......@@ -123,10 +123,16 @@ class CasServerController extends ZendAfi_Controller_Action {
public function loginAction() {
$this->_addParamsOnRequest();
$this->_forward('login', 'auth');
}
public function _addParamsOnRequest() {
return $this;
}
public function logoutAction() {
ZendAfi_Auth::getInstance()->clearIdentity();
if ($url_redirect = $this->_getParam('url'))
......
......@@ -45,5 +45,11 @@ class CasServerV3Controller extends CasServerController {
protected function _getCasTicket($service) {
return (new Class_CasTicketV3($service));
}
public function _addParamsOnRequest() {
$this->_request->setParam('cas','v3');
return $this;
}
}
?>
......@@ -50,6 +50,7 @@ trait Trait_Auth_CasAware {
return $url_musicme;
$ticket = $this->_getCasTicket()->getTicketForCurrentUser();
$queries = [];
$url_cas = array_merge(['query'=> '', 'path' => ''],
parse_url($this->_getServerUrl()));
......@@ -63,6 +64,22 @@ trait Trait_Auth_CasAware {
}
protected function _hasPermission() {
$service = $this->_getServerUrl();
if (!$user = Class_Users::getIdentity())
return false;
$digital_resource = Class_DigitalResource::getInstance();
return ($plugin = $digital_resource->getPluginsSSOActions()
->detect(function ($plugin) use ($service) {
return FALSE !== stristr($service, $plugin);
}))
? $digital_resource->hasPermissionOn($plugin, $user)
: true;
}
protected function _redirectMusicme() {
return (strpos($this->_getServerUrl(), 'musicme') !== false)
? Musicme_Config::getInstance()->getSsoUrl(Class_Users::getIdentity())
......@@ -77,6 +94,10 @@ class Class_Auth_CasLogged extends Class_Auth_Logged {
use Trait_Auth_CasAware;
public function prepareLogin() {
if (!$this->_hasPermission()) {
$this->controller->notify($this->_('Vous n\'avez pas les droits d\'accès à la ressource'));
return $this->redirect_url= '/opac';
}
$this->_getCasTicket()->save();
......@@ -93,6 +114,11 @@ class Class_Auth_CasNotLogged extends Class_Auth_NotLogged {
use Trait_Auth_CasAware;
protected function _doOnLoginSuccess() {
if (!$this->_hasPermission()) {
$this->controller->notify($this->_('Vous n\'avez pas les droits d\'accès à la ressource'));
return $this->redirect_url = '/opac';
}
$this->_getCasTicket()->save();
$this->redirect_url = $this->_urlServiceCas();
......
......@@ -28,7 +28,8 @@ class Class_CasTicket {
public static function newFor($request) {
return ($service = $request->getParam('service'))
&& ($request->getParam('controller') == 'cas-server-v3')
&& (($request->getParam('controller') == 'cas-server-v3')
|| $request->getParam('cas','') == 'v3')
? new Class_CasTicketV3($service)
: (new Class_CasTicket());
}
......@@ -89,8 +90,8 @@ class Class_CasTicket {
public function userForTicket($ticket) {
if (($id = (new Storm_Cache())->load($this->withoutPrefix($ticket)))
&& !is_array($id))
return Class_Users::find($id);
&& !is_object($id))
return Class_Users::find((int)$id);
$this->_setErrorCode(static::CODE_INVALID_TICKET);
return;
}
......
......@@ -64,6 +64,12 @@ class Class_CasTicketV3 extends Class_CasTicket{
return;
}
if (!$cas_cache instanceof CasTicketV3Cache) {
$this->_setErrorCode(static::CODE_INVALID_SERVICE);
$this->clear($ticket);
return;
}
if ($cas_cache->getService() != $this->_service) {
$this->_setErrorCode(static::CODE_INVALID_SERVICE);
$this->clear($ticket);
......
......@@ -102,7 +102,6 @@ class Class_WebService_OPDS_CatalogReader {
return;
}
if(array_key_exists('REL', $attributes) && ('http://opds-spec.org/image/thumbnail' == $attributes['REL']))
$this->_current_entry->setThumbnail($attributes['HREF']);
......
......@@ -120,12 +120,19 @@ class ZendAfi_Form_Login extends ZendAfi_Form {
}
if(strlen($this->_service)>1){
$this->addElement('hidden',
'service',
['value' => $this->_service]);
array_push($group, 'redirect');
array_push($group, 'service');
}
if (isset($this->_data['cas']) && $this->_data['cas'] == 'v3') {
$this->addElement('hidden',
'cas',
['value' => 'v3']);
array_push($group, 'cas');
}
......@@ -159,4 +166,4 @@ class ZendAfi_Form_Login extends ZendAfi_Form {
$title = $element->placeholder ? $element->placeholder : $default;
$element->setAttrib('title', $title);
}
}
\ No newline at end of file
}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Artips_Batch extends Class_DigitalResource_Batch {}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Artips_Config extends Class_DigitalResource_Config {
protected function _getConfig() {
return ['Introduction' => $this->_('Artips'),
'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/Artips',
'Url' => 'https://artips.fr',
'Icon' => 'https://artips.fr/resources/img/artips/artips.png',
'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource Artips'),
'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'),
'SsoAction' => true,
'MenuLabel' => $this->_('Lien vers Artips'),
'ModuleMenu' => $this->withNameSpace('ModuleMenu'),
'Service' => $this->withNameSpace('Service'),
'Batch' => $this->withNameSpace('Batch'),
'DocTypeLabel' => $this->_('Capsules de culture Artips'),
'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme Artips'))->bePrivate(),
'OPDS_CATALOG_URL' => Class_AdminVar_Meta::newDefault($this->_('URL du catalogue OPDS de la plateforme Artips'))->bePrivate()
]
];
}
public function isEnabled() {
return '' != $this->getAdminVar('SSO_URL');
}
public function getSsoUrl($user) {
return $this->getAdminVar('SSO_URL');
}
public function getAlbumSsoUrl($user, $album) {
if(!$album)
return '';
return $album->getExternalUri();
}
public function getHarvestUrl($page = 1) {
$query = ['lang' => 'fr',
'format' => 'OPDS'];
$url = $this->getAdminVar('OPDS_CATALOG_URL');
return $url . '?' . http_build_query(array_filter($query));
}
}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Artips_ModuleMenu extends Class_DigitalResource_ModuleMenu {}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Artips_Service extends Class_DigitalResource_Service {
public function getPageCount() {
return 1;
}
public function getRessourcesNumeriques() {
return $this->_parser->getEntries();
}
public function loadPage($page_number = 1) {
$opds = $this->httpGet($this->_config->getHarvestUrl($page_number));
$this->_parser = (new Artips_Service_CatalogReader)->parse($opds);
return $this;
}
}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Artips_Service_Album extends Class_WebService_OPDS_CatalogEntry {
public function getBaseUrl() {
return Artips_Config::getInstance()->getAdminVar('SSO_URL');
}
protected function getTypeDoc() {
return Artips_Config::getInstance()->getDocType();
}
public function fillAlbum($album) {
$album
->setTypeDocId($this->getTypeDoc());
return $this;
}
public function matchId($other_id) {
return $this->getId() === $other_id;
}
public function setId($id) {
$this->_id = $id;
return $this;
}
public function getRessourceCategorieLibelle() {
return Artips_Config::getInstance()->getDocTypeLabel();
}
public function setPoster($thumbnail) {
return $this->addPoster($thumbnail);
}
}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Artips_Service_CatalogReader extends Class_WebService_OPDS_CatalogReader {
protected $_authors = [];
public function startEntry() {
$this->_current_entry = new Artips_Service_Album();
foreach ($this->_authors as $author)
$this->_current_entry->addAuthor($author);
$this->_entries[] = $this->_current_entry;
}
public function startLink($attributes) {
if (!array_key_exists('TYPE', $attributes))
return $this;
if (!$this->_xml_parser->inParents('entry'))
return $this;
if(array_key_exists('REL', $attributes) && ('thumbnail' == $attributes['REL']))
$this->_current_entry->setThumbnail($attributes['HREF']);
if(array_key_exists('REL', $attributes) && ('image' == $attributes['REL']))
$this->_current_entry->setPoster($attributes['HREF']);
if(array_key_exists('REL', $attributes) && ('related' == $attributes['REL']))
$this->_current_entry->setExternalUri($attributes['HREF']);
return $this;
}
public function endName($data) {
if (!$this->_xml_parser->inParents('author'))
return $this;
if ($this->_xml_parser->inParents('entry'))
return $this->_current_entry->addAuthor($data);
$this->_authors[] = $data;
return $this;
}
public function endIdentifier($data) {
$this->endId($data);
}
public function endDescription($data) {
return $this->_current_entry->setDescription($data);
}
public function endSummary($data) {
return $this->_current_entry->setSubtitle($data);
}
public function endSubject($label) {
if (!$this->_xml_parser->inParents('entry'))
return;
return $this->_current_entry->addMatiere($label);
}
}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Artips_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Artips_Plugin_IndexController extends Class_DigitalResource_Controller {}
library/digital_resources/Artips/images/favicon.ico

16.2 KiB

library/digital_resources/Artips/images/icon-1.png

992 B

0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment