Put back ExternalSso for #585

Not the most secure, needs improvements
This commit is contained in:
the-djmaze 2022-10-27 10:43:33 +02:00
parent 256023dc58
commit e06acbe738
2 changed files with 29 additions and 4 deletions

View file

@ -387,6 +387,8 @@ Enables caching in the system'),
'custom_login_link' => array(''),
'custom_logout_link' => array(''),
'allow_external_login' => array(false),
'allow_external_sso' => array(false),
'external_sso_key' => array(''),
'http_client_ip_check_proxy' => array(false),
'fast_cache_memcache_host' => array('127.0.0.1'),
'fast_cache_memcache_port' => array(11211),

View file

@ -811,10 +811,33 @@ class ServiceActions
return '';
}
/**
* @return mixed
*/
public function ErrorTemplates(string $sTitle, string $sDesc, bool $bShowBackLink = true)
public function ServiceExternalSso() : string
{
$this->oHttp->ServerNoCache();
$sResult = '';
$oConfig = $this->oActions->Config();
$sKey = $oConfig->Get('labs', 'external_sso_key', '');
$sEmail = \trim($this->oHttp->GetRequest('Email', ''));
$sPassword = $this->oHttp->GetRequest('Password', '');
if ($oConfig->Get('labs', 'allow_external_sso', false)
&& $sEmail && $sPassword
&& $sKey && $this->oHttp->GetRequest('SsoKey', '') == $sKey
) {
$sResult = \RainLoop\Api::CreateUserSsoHash($sEmail, $sPassword);
if ('json' == \strtolower($this->oHttp->GetRequest('Output', 'Plain'))) {
\header('Content-Type: application/json; charset=utf-8');
$sResult = \json_encode(array(
'Action' => 'ExternalSso',
'Result' => $sResult
));
} else {
\header('Content-Type: text/plain');
}
}
return $sResult;
}
public function ErrorTemplates(string $sTitle, string $sDesc, bool $bShowBackLink = true) : string
{
return \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Error.html'), array(
'{{ErrorTitle}}' => $sTitle,