mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°4784 - CAS authentication issue with iTop 3.0
* Fix regression when setting cas as first login mode
This commit is contained in:
@@ -29,6 +29,8 @@ use utils;
|
|||||||
*/
|
*/
|
||||||
class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExtension, iLoginUIExtension
|
class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExtension, iLoginUIExtension
|
||||||
{
|
{
|
||||||
|
const LOGIN_MODE = 'cas';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of supported login modes for this plugin
|
* Return the list of supported login modes for this plugin
|
||||||
*
|
*
|
||||||
@@ -36,7 +38,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte
|
|||||||
*/
|
*/
|
||||||
public function ListSupportedLoginModes()
|
public function ListSupportedLoginModes()
|
||||||
{
|
{
|
||||||
return array('cas');
|
return array(static::LOGIN_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function OnStart(&$iErrorCode)
|
protected function OnStart(&$iErrorCode)
|
||||||
@@ -47,12 +49,12 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte
|
|||||||
|
|
||||||
protected function OnReadCredentials(&$iErrorCode)
|
protected function OnReadCredentials(&$iErrorCode)
|
||||||
{
|
{
|
||||||
if (Session::Get('login_mode') == 'cas')
|
if (empty(Session::Get('login_mode')) || Session::Get('login_mode') == static::LOGIN_MODE)
|
||||||
{
|
{
|
||||||
static::InitCASClient();
|
static::InitCASClient();
|
||||||
if (phpCAS::isAuthenticated())
|
if (phpCAS::isAuthenticated())
|
||||||
{
|
{
|
||||||
Session::Set('login_mode', 'cas');
|
Session::Set('login_mode', static::LOGIN_MODE);
|
||||||
Session::Set('auth_user', phpCAS::getUser());
|
Session::Set('auth_user', phpCAS::getUser());
|
||||||
Session::Unset('login_will_redirect');
|
Session::Unset('login_will_redirect');
|
||||||
}
|
}
|
||||||
@@ -68,7 +70,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte
|
|||||||
$iErrorCode = LoginWebPage::EXIT_CODE_MISSINGLOGIN;
|
$iErrorCode = LoginWebPage::EXIT_CODE_MISSINGLOGIN;
|
||||||
return LoginWebPage::LOGIN_FSM_ERROR;
|
return LoginWebPage::LOGIN_FSM_ERROR;
|
||||||
}
|
}
|
||||||
Session::Set('login_mode', 'cas');
|
Session::Set('login_mode', static::LOGIN_MODE);
|
||||||
phpCAS::forceAuthentication(); // Redirect to CAS and exit
|
phpCAS::forceAuthentication(); // Redirect to CAS and exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +79,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte
|
|||||||
|
|
||||||
protected function OnCheckCredentials(&$iErrorCode)
|
protected function OnCheckCredentials(&$iErrorCode)
|
||||||
{
|
{
|
||||||
if (Session::Get('login_mode') == 'cas')
|
if (Session::Get('login_mode') == static::LOGIN_MODE)
|
||||||
{
|
{
|
||||||
if (!Session::IsSet('auth_user'))
|
if (!Session::IsSet('auth_user'))
|
||||||
{
|
{
|
||||||
@@ -94,7 +96,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte
|
|||||||
|
|
||||||
protected function OnCredentialsOK(&$iErrorCode)
|
protected function OnCredentialsOK(&$iErrorCode)
|
||||||
{
|
{
|
||||||
if (Session::Get('login_mode') == 'cas')
|
if (Session::Get('login_mode') == static::LOGIN_MODE)
|
||||||
{
|
{
|
||||||
$sAuthUser = Session::Get('auth_user');
|
$sAuthUser = Session::Get('auth_user');
|
||||||
if (!LoginWebPage::CheckUser($sAuthUser))
|
if (!LoginWebPage::CheckUser($sAuthUser))
|
||||||
@@ -109,7 +111,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte
|
|||||||
|
|
||||||
protected function OnError(&$iErrorCode)
|
protected function OnError(&$iErrorCode)
|
||||||
{
|
{
|
||||||
if (Session::Get('login_mode') == 'cas')
|
if (Session::Get('login_mode') == static::LOGIN_MODE)
|
||||||
{
|
{
|
||||||
Session::Unset('phpCAS');
|
Session::Unset('phpCAS');
|
||||||
if ($iErrorCode != LoginWebPage::EXIT_CODE_MISSINGLOGIN)
|
if ($iErrorCode != LoginWebPage::EXIT_CODE_MISSINGLOGIN)
|
||||||
@@ -124,7 +126,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte
|
|||||||
|
|
||||||
protected function OnConnected(&$iErrorCode)
|
protected function OnConnected(&$iErrorCode)
|
||||||
{
|
{
|
||||||
if (Session::Get('login_mode') == 'cas')
|
if (Session::Get('login_mode') == static::LOGIN_MODE)
|
||||||
{
|
{
|
||||||
Session::Set('can_logoff', true);
|
Session::Set('can_logoff', true);
|
||||||
return LoginWebPage::CheckLoggedUser($iErrorCode);
|
return LoginWebPage::CheckLoggedUser($iErrorCode);
|
||||||
@@ -205,7 +207,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte
|
|||||||
$oLoginContext->SetLoaderPath(APPROOT.'env-'.utils::GetCurrentEnvironment().'/authent-cas/view');
|
$oLoginContext->SetLoaderPath(APPROOT.'env-'.utils::GetCurrentEnvironment().'/authent-cas/view');
|
||||||
|
|
||||||
$aData = array(
|
$aData = array(
|
||||||
'sLoginMode' => 'cas',
|
'sLoginMode' => static::LOGIN_MODE,
|
||||||
'sLabel' => Dict::S('CAS:Login:SignIn'),
|
'sLabel' => Dict::S('CAS:Login:SignIn'),
|
||||||
'sTooltip' => Dict::S('CAS:Login:SignInTooltip'),
|
'sTooltip' => Dict::S('CAS:Login:SignInTooltip'),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user