Skip to content
Snippets Groups Projects
Commit 1cebab37 authored by Laurent's avatar Laurent
Browse files

Merge branch 'dev#155214_ensa_omeka_s_get_way' into 'master'

Dev#155214 ensa omeka s get way

See merge request !4439
parents fd5176ae c3400a03
1 merge request!4439Dev#155214 ensa omeka s get way
Pipeline #17393 failed with stage
in 57 minutes and 15 seconds
- fonctionnalité #155214 : seveur CAS : prise en compte du paramètre 'gateway' qui permet de rediriger l'utilisateur sans demander l'authentification
\ No newline at end of file
......@@ -117,6 +117,16 @@ class Class_Auth_CasLogged extends Class_Auth_Logged {
class Class_Auth_CasNotLogged extends Class_Auth_NotLogged {
use Trait_Auth_CasAware;
public function processLogin() {
if ($this->_getParam('gateway')) {
$this->redirect_url = $this->_getServerUrl();
return $this->_handleRedirect();
}
return parent::processLogin();
}
protected function _doOnLoginSuccess() {
if (!$this->_hasPermission()) {
$this->controller->notify($this->_('Vous n\'avez pas les droits d\'accès à la ressource'));
......
......@@ -43,10 +43,11 @@ class OmekaS_Plugin_IndexController extends Class_DigitalResource_Controller {
if ($profile_serializer->isSsoMandatory($sso_type) || Class_Users::hasIdentity()) {
$url = ($base_url = $data_profile->getItemBaseUrl())
? $base_url . 'cas/login?redirect_url=' . urlencode($url)
? $base_url . 'cas/login?' . http_build_query(['gateway' => 'true',
'redirect_url' => $url])
: $url_404;
}
$this->_javascriptRedirectTo($url);
}
}
\ No newline at end of file
}
......@@ -135,6 +135,25 @@ class CasServerControllerValidateActionTest extends AbstractControllerTestCase {
}
/** @test */
public function loginOnCasOneZeroWithGatewayTrueShouldRedirectToServiceWithoutTicket() {
ZendAfi_Auth::getInstance()->clearIdentity();
$this->dispatch(sprintf('/opac/cas-server-v10/login?service=%s&gateway=true',
urlencode('http://test.com?ressource_id=1234&message=go')));
$this->assertRedirectTo('http://test.com?ressource_id=1234&message=go',
$this->getResponseLocation());
}
/** @test */
public function loginOnCasOneZeroWithGatewayTagadaShouldRedirectToServiceWithoutTicket() {
ZendAfi_Auth::getInstance()->clearIdentity();
$this->dispatch('/opac/cas-server-v10/login?service=http://test.com&gateway=tagada');
$this->assertRedirectTo('http://test.com',
$this->getResponseLocation());
}
/** @test */
public function loginOnCasOneZeroWithoutOpenedSessionShouldDisplayLoginForm() {
ZendAfi_Auth::getInstance()->clearIdentity();
......
......@@ -99,7 +99,7 @@ class OmekaSViewNoticeLoggedTest extends OmekaSViewNoticeTestCase {
/** @test */
public function moduleSsoActionShouldRedirectToOmekaServerWithCasWhenMandatory() {
$this->dispatch('/modules/sso/id/1288');
$this->assertContains('document.location.href="https://omekas.myserver.com/cas/login?redirect_url=https%3A%2F%2Fomekas.myserver.com%2Fs%2Fslug%2Fitem%2F88398"',
$this->assertContains('document.location.href="https://omekas.myserver.com/cas/login?gateway=true&redirect_url=https%3A%2F%2Fomekas.myserver.com%2Fs%2Fslug%2Fitem%2F88398"',
$this->_response->getBody());
}
......@@ -108,7 +108,7 @@ class OmekaSViewNoticeLoggedTest extends OmekaSViewNoticeTestCase {
public function moduleSsoActionShouldRedirectToOmekaServerWithCasWhenOptional() {
$this->_setItemCasSso(2);
$this->dispatch('/modules/sso/id/1288');
$this->assertContains('document.location.href="https://omekas.myserver.com/cas/login?redirect_url=https%3A%2F%2Fomekas.myserver.com%2Fs%2Fslug%2Fitem%2F88398"',
$this->assertContains('document.location.href="https://omekas.myserver.com/cas/login?gateway=true&redirect_url=https%3A%2F%2Fomekas.myserver.com%2Fs%2Fslug%2Fitem%2F88398"',
$this->_response->getBody());
}
......@@ -150,7 +150,7 @@ class OmekaSViewNoticeNotLoggedTest extends OmekaSViewNoticeTestCase {
/** @test */
public function moduleSsoActionShouldRedirectToOmekaServerWithCasWhenMandatory() {
$this->dispatch('/modules/sso/id/1288');
$this->assertContains('document.location.href="https://omekas.myserver.com/cas/login?redirect_url=https%3A%2F%2Fomekas.myserver.com%2Fs%2Fslug%2Fitem%2F88398"',
$this->assertContains('document.location.href="https://omekas.myserver.com/cas/login?gateway=true&redirect_url=https%3A%2F%2Fomekas.myserver.com%2Fs%2Fslug%2Fitem%2F88398"',
$this->_response->getBody());
}
......
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