From 5f8608883d9195d70829de3886e6d6a95f8dec09 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Tue, 3 Apr 2018 12:06:53 +0200 Subject: [PATCH] dev #68179 upgrade StoryPlayR SSO --- .../digital_resources/StoryPlayR/Config.php | 20 ++++++++++++------- .../StoryPlayR/tests/StoryPlayRTest.php | 10 ++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/library/digital_resources/StoryPlayR/Config.php b/library/digital_resources/StoryPlayR/Config.php index 63ffbf5e93e..f07fbadd4e3 100644 --- a/library/digital_resources/StoryPlayR/Config.php +++ b/library/digital_resources/StoryPlayR/Config.php @@ -54,7 +54,7 @@ class StoryPlayR_Config extends Class_DigitalResource_Config { return ''; return $this->getAdminVar('SSO_URL') - . '?' + . '?target=/bibliotheque&' . $this->_getSsoQuery($user); } @@ -74,9 +74,7 @@ class StoryPlayR_Config extends Class_DigitalResource_Config { public function validateUrlFor($user) { - return Class_Url::absolute(['module' => $this->getModuleName(), - 'controller' => 'auth', - 'action' => 'validate'], null, true) + return $this->_validateUrl() . '?' . http_build_query(['sessionid' => (new Class_CasTicket())->getTicketForUser($user)]); } @@ -96,9 +94,17 @@ class StoryPlayR_Config extends Class_DigitalResource_Config { protected function _getSsoQuery($user) { return $user - ? http_build_query(['userid' => $user->getLogin(), - 'mediathequeid' => $this->getAdminVar('MEDIATHEQUE_ID'), - 'sessionid' => (new Class_CasTicket())->getTicketForUser($user)]) + ? (http_build_query(['userid' => $user->getLogin(), + 'mediathequeid' => $this->getAdminVar('MEDIATHEQUE_ID'), + 'sessionid' => (new Class_CasTicket())->getTicketForUser($user)]) + . '&check_url=' . $this->_validateUrl()) : ''; } + + + protected function _validateUrl() { + return Class_Url::absolute(['module' => $this->getModuleName(), + 'controller' => 'auth', + 'action' => 'validate'], null, true); + } } \ No newline at end of file diff --git a/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php b/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php index fe51eea85eb..7ca6b328094 100644 --- a/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php +++ b/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php @@ -26,7 +26,7 @@ class StoryPlayRActivatedTestCase extends AbstractControllerTestCase { public function setUp() { parent::setUp(); - Class_AdminVar::set('StoryPlayR_SSO_URL', 'https://www.storyplayr.com/api/assa/login'); + Class_AdminVar::set('StoryPlayR_SSO_URL', 'https://www.storyplayr.com/api/bokeh/login'); Class_AdminVar::set('StoryPlayR_MEDIATHEQUE_ID', 123456); $group = $this->fixture('Class_UserGroup', @@ -59,7 +59,13 @@ class StoryPlayRSsoTest extends StoryPlayRActivatedTestCase { /** @test */ public function shouldRedirectToStoryPlayer() { - $this->assertXPathContentContains('//script' , 'document.location.href="https://www.storyplayr.com/api/assa/login?userid=Tom&mediathequeid=123456&sessionid=ST-', $this->_response->getBody()); + $this->assertXPathContentContains('//script' , 'document.location.href="https://www.storyplayr.com/api/bokeh/login?target=/bibliotheque&userid=Tom&mediathequeid=123456&sessionid=ST-', $this->_response->getBody()); + } + + + /** @test */ + public function scriptShouldContainsCheckUrl() { + $this->assertXPathContentContains('//script' , '&check_url=http://localhost/ghislo/StoryPlayR_Plugin/auth/validate', $this->_response->getBody()); } } -- GitLab