mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
WIP Mail REST API: fix broken fallback auth
This commit is contained in:
parent
18b60c1638
commit
9a559c5000
@ -81,34 +81,39 @@ class Auth
|
|||||||
*/
|
*/
|
||||||
static function backend($type=null, $save_in_session=true)
|
static function backend($type=null, $save_in_session=true)
|
||||||
{
|
{
|
||||||
if (is_null($type))
|
if (!isset($type))
|
||||||
{
|
{
|
||||||
$type = self::backendType() ?: null;
|
$type = self::backendType() ?: null;
|
||||||
}
|
}
|
||||||
// do we have a hostname specific auth type set
|
// do we have a hostname specific auth type set
|
||||||
if (is_null($type) && !empty($GLOBALS['egw_info']['server']['auth_type_host']) &&
|
if (!isset($type) && !empty($GLOBALS['egw_info']['server']['auth_type_host']) &&
|
||||||
Header\Http::host() === $GLOBALS['egw_info']['server']['auth_type_hostname'])
|
Header\Http::host() === $GLOBALS['egw_info']['server']['auth_type_hostname'])
|
||||||
{
|
{
|
||||||
$type = $GLOBALS['egw_info']['server']['auth_type_host'];
|
$type = $GLOBALS['egw_info']['server']['auth_type_host'];
|
||||||
}
|
}
|
||||||
if (is_null($type)) $type = $GLOBALS['egw_info']['server']['auth_type'];
|
if (!isset($type))
|
||||||
|
{
|
||||||
|
$type = $GLOBALS['egw_info']['server']['auth_type'];
|
||||||
|
|
||||||
$account_storage = $GLOBALS['egw_info']['server']['account_storage'] ?? $type;
|
$account_repository = $GLOBALS['egw_info']['server']['account_repository'] ?? $type;
|
||||||
if (!empty($GLOBALS['egw_info']['server']['auth_fallback']) && $type !== $account_storage)
|
if (!empty($GLOBALS['egw_info']['server']['auth_fallback']) && $type !== $account_repository)
|
||||||
{
|
{
|
||||||
$backend = new Auth\Fallback($type, $account_storage);
|
$backend = new Auth\Fallback($type, $account_repository);
|
||||||
self::log("Instantiated Auth\\Fallback('$type', '$account_storage')");
|
self::log("Instantiated Auth\\Fallback('$type', '$account_repository')");
|
||||||
|
$type = "fallback:$type:$account_repository";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (!isset($backend))
|
||||||
{
|
{
|
||||||
$backend_class = __CLASS__.'\\'.ucfirst($type);
|
[$t, $p1, $p2] = explode(':', $type)+[null,null,null];
|
||||||
|
$backend_class = __CLASS__.'\\'.ucfirst($t);
|
||||||
|
|
||||||
// try old location / name, if not found
|
// try old location / name, if not found
|
||||||
if (!class_exists($backend_class) && class_exists('auth_'.$type))
|
if (!class_exists($backend_class) && class_exists('auth_'.$t))
|
||||||
{
|
{
|
||||||
$backend_class = 'auth_'.$type;
|
$backend_class = 'auth_'.$t;
|
||||||
}
|
}
|
||||||
$backend = new $backend_class;
|
$backend = new $backend_class($p1, $p2);
|
||||||
self::log("Instantiated $backend_class() (for type '$type')");
|
self::log("Instantiated $backend_class() (for type '$type')");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +43,10 @@ class Fallback implements Backend
|
|||||||
*/
|
*/
|
||||||
function __construct($primary='ldap',$fallback='sql')
|
function __construct($primary='ldap',$fallback='sql')
|
||||||
{
|
{
|
||||||
$this->primary_backend = Api\Auth::backend(str_replace('auth_', '', $primary));
|
// do NOT save our backends in session, as we want "fallback" to be saved
|
||||||
|
$this->primary_backend = Api\Auth::backend(str_replace('auth_', '', $primary), false);
|
||||||
|
|
||||||
$this->fallback_backend = Api\Auth::backend(str_replace('auth_', '', $fallback));
|
$this->fallback_backend = Api\Auth::backend(str_replace('auth_', '', $fallback), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user