Fix owncloud template

Fix sso (logout on empty hash)
This commit is contained in:
RainLoop Team 2014-05-20 02:11:54 +04:00
parent 71af876fb5
commit 8ac9920ec8
8 changed files with 59 additions and 15 deletions

View file

@ -5,15 +5,13 @@ namespace RainLoop;
use RainLoop\Enumerations\UploadError;
use RainLoop\Enumerations\UploadClientError;
define('RL_CONTACTS_PER_PAGE', 30);
define('RL_CONTACTS_MAX', 300);
class Actions
{
const AUTH_TFA_SIGN_ME_TOKEN_KEY = 'rltfasmauth';
const AUTH_SIGN_ME_TOKEN_KEY = 'rlsmauth';
const AUTH_MAILTO_TOKEN_KEY = 'rlmailtoauth';
const AUTH_SPEC_TOKEN_KEY = 'rlspecauth';
const AUTH_SPEC_LOGOUT_TOKEN_KEY = 'rlspeclogout';
const AUTH_ADMIN_TOKEN_KEY = 'rlaauth';
const AUTH_LAST_ERROR = 'rllasterrorcode';
@ -359,6 +357,14 @@ class Actions
return $sFileName;
}
/**
* @return void
*/
public function SetAuthLogoutToken()
{
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, \md5(APP_START_TIME), 0, '/', null, null, true);
}
/**
* @param \RainLoop\Account $oAccount
*
@ -400,6 +406,20 @@ class Actions
return $sResult;
}
/**
* @return string
*/
public function GetSpecAuthLogoutTokenWithDeletion()
{
$sResult = \RainLoop\Utils::GetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, '');
if (0 < strlen($sResult))
{
\RainLoop\Utils::ClearCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY);
}
return $sResult;
}
/**
* @return void
*/
@ -5983,17 +6003,17 @@ class Actions
return $this->DefaultResponse(__FUNCTION__, true);
}
/**
* @param bool $bAdmin
* @param \RainLoop\Account $oAccount
*
*
* @return array
*/
public function Capa($bAdmin, $oAccount = null)
{
$oConfig = $this->Config();
$aResult = array(\RainLoop\Enumerations\Capa::PREM);
if ($oConfig->Get('webmail', 'allow_additional_accounts', false))

View file

@ -736,6 +736,7 @@ class ServiceActions
{
$oException = null;
$oAccount = null;
$bLogout = true;
$sSsoHash = $this->oHttp->GetRequest('hash', '');
if (!empty($sSsoHash))
@ -762,6 +763,7 @@ class ServiceActions
$oAccount = $this->oActions->LoginProcess($sEmail, $sLogin, $sPassword);
$this->oActions->AuthProcess($oAccount);
$bLogout = !($oAccount instanceof \RainLoop\Account);
}
catch (\Exception $oException)
{
@ -771,6 +773,11 @@ class ServiceActions
}
}
if ($bLogout)
{
$this->oActions->SetAuthLogoutToken();
}
$this->oActions->Location('./');
return '';
}
@ -782,6 +789,7 @@ class ServiceActions
{
$oException = null;
$oAccount = null;
$bLogout = true;
$sEmail = $this->oHttp->GetEnv('REMOTE_USER', '');
$sLogin = '';
@ -795,6 +803,7 @@ class ServiceActions
$oAccount = $this->oActions->LoginProcess($sEmail, $sLogin, $sPassword);
$this->oActions->AuthProcess($oAccount);
$bLogout = !($oAccount instanceof \RainLoop\Account);
}
catch (\Exception $oException)
{
@ -802,6 +811,11 @@ class ServiceActions
}
}
if ($bLogout)
{
$this->oActions->SetAuthLogoutToken();
}
$this->oActions->Location('./');
return '';
}
@ -813,6 +827,7 @@ class ServiceActions
{
$oException = null;
$oAccount = null;
$bLogout = true;
if ($this->oActions->Config()->Get('labs', 'allow_external_login', false))
{
@ -826,11 +841,17 @@ class ServiceActions
$oAccount = $this->oActions->LoginProcess($sEmail, $sLogin, $sPassword);
$this->oActions->AuthProcess($oAccount);
$bLogout = !($oAccount instanceof \RainLoop\Account);
}
catch (\Exception $oException)
{
$this->oActions->Logger()->WriteException($oException);
}
if ($bLogout)
{
$this->oActions->SetAuthLogoutToken();
}
}
switch (\strtolower($this->oHttp->GetRequest('Output', 'Redirect')))
@ -883,6 +904,7 @@ class ServiceActions
\RainLoop\Api::Handle();
$sResult = \RainLoop\Api::GetUserSsoHash($sEmail, $sPassword, $sLogin);
$bLogout = 0 === \strlen($sResult);
switch (\strtolower($this->oHttp->GetRequest('Output', 'Plain')))
{
@ -959,7 +981,7 @@ class ServiceActions
$this->oHttp->ServerNoCache();
$sAuthAccountHash = '';
if (!$bAdmin)
if (!$bAdmin && 0 === \strlen($this->oActions->GetSpecAuthLogoutTokenWithDeletion()))
{
$sAuthAccountHash = $this->oActions->GetSpecAuthTokenWithDeletion();
if (empty($sAuthAccountHash))