mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Trying different sso type (PHP) for ownCloud package
This commit is contained in:
parent
777d014403
commit
1d39879765
12 changed files with 81 additions and 70 deletions
|
|
@ -2,37 +2,47 @@
|
|||
|
||||
class OC_RainLoop_Helper
|
||||
{
|
||||
public static function getSsoHash($sUrl, $sSsoKey, $sEmail, $sPassword)
|
||||
/**
|
||||
* @param string $sPath
|
||||
* @param string $sEmail
|
||||
* @param string $sPassword
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSsoHash($sPath, $sEmail, $sPassword)
|
||||
{
|
||||
if (!function_exists('curl_init'))
|
||||
$SsoHash = '';
|
||||
|
||||
$sPath = rtrim(trim($sPath), '\\/').'/index.php';
|
||||
if (file_exists($sPath))
|
||||
{
|
||||
return '';
|
||||
$_ENV['RAINLOOP_INCLUDE_AS_API'] = false;
|
||||
include $sPath;
|
||||
|
||||
if (class_exists($sPath))
|
||||
{
|
||||
|
||||
$SsoHash = \RainLoop\Api::GetUserSsoHash($sEmail, $sPassword);
|
||||
}
|
||||
}
|
||||
|
||||
return $SsoHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sUrl
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function normalizeUrl($sUrl)
|
||||
{
|
||||
$sUrl = \rtrim($sUrl, '/\\');
|
||||
if ('.php' !== \strtolower(\substr($sUrl), -4))
|
||||
{
|
||||
$sUrl .= '/';
|
||||
}
|
||||
|
||||
$oCurl = curl_init();
|
||||
curl_setopt_array($oCurl, array(
|
||||
CURLOPT_URL => $sUrl.'?ExternalSso',
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_FAILONERROR => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_USERAGENT => 'RainLoop SSO User Agent (ownCloud)',
|
||||
CURLOPT_POSTFIELDS => http_build_query(array(
|
||||
'SsoKey' => $sSsoKey,
|
||||
'Email' => $sEmail,
|
||||
'Password' => $sPassword
|
||||
), '', '&'),
|
||||
CURLOPT_TIMEOUT => 5
|
||||
));
|
||||
|
||||
$mResult = curl_exec($oCurl);
|
||||
if (is_resource($oCurl))
|
||||
{
|
||||
curl_close($oCurl);
|
||||
}
|
||||
|
||||
return is_string($mResult) ? $mResult : '';
|
||||
return $sUrl;
|
||||
}
|
||||
|
||||
public static function encodePassword($sPassword, $sSalt)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue