* CalDAV/CardDAV: fix freebusy-URL for users and support basic auth with regular user credentials too

This commit is contained in:
Ralf Becker 2021-04-13 15:55:18 +02:00
parent 4af0bec278
commit 38ef0e0a94
3 changed files with 32 additions and 12 deletions

View File

@ -401,6 +401,15 @@ class addressbook_vcal extends addressbook_bo
}
break;
case 'freebusy_uri':
// fix Freebusy URL for users
if (!empty($entry['account_id']) && ($user = Api\Accounts::id2name($entry['account_id'])))
{
$value = Api\Header\Http::fullUrl(Api\Framework::link('/calendar/freebusy.php', ['user' => $user]));
}
if (!empty($value)) $hasdata++;
break;
case 'n_fn':
case 'fileas_type':
// mark entries with fileas_type == 'org_name' as X-ABSHOWAS:COMPANY (Apple AB specific)

View File

@ -19,11 +19,21 @@ $GLOBALS['egw_info'] = array(
'nofooter' => True,
),
);
// check if we are loged in, by checking sessionid and kp3, as the sessionid get set automaticaly by php for php4-sessions
if (!($loged_in = !empty($_COOKIE['sessionid'])))
// check if we are already logged in
require_once __DIR__.'/../api/src/autoload.php';
if (!($logged_in = !empty(Api\Session::get_sessionid())))
{
$GLOBALS['egw_info']['flags']['currentapp'] = 'login';
$GLOBALS['egw_info']['flags']['noapi'] = True;
// support basic auth for regular user-credentials
if (!empty($_SERVER['PHP_AUTH_PW']) || !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']))
{
$GLOBALS['egw_info']['flags']['autocreate_session_callback'] = Api\Header\Authenticate::class.'::autocreate_session_callback';
$logged_in = true; // header sends 401, if not authenticated
}
else
{
$GLOBALS['egw_info']['flags']['currentapp'] = 'login';
$GLOBALS['egw_info']['flags']['noapi'] = True;
}
}
include ('../header.inc.php');
@ -32,10 +42,11 @@ function fail_exit($msg)
echo "<html>\n<head>\n<title>$msg</title>\n<meta http-equiv=\"content-type\" content=\"text/html; charset=".
Api\Translation::charset()."\" />\n</head>\n<body><h1>$msg</h1>\n</body>\n</html>\n";
exit();
http_response_code(401);
exit;
}
if (!$loged_in)
if (!$logged_in)
{
include ('../api/src/loader.php');
$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
@ -59,7 +70,7 @@ if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user)))
{
fail_exit(lang("freebusy: unknown user '%1', wrong password or not available to not logged in users !!!"." $username($user)",$_GET['user']));
}
if (!$loged_in)
if (!$logged_in)
{
if (empty($_GET['cred']))
{
@ -68,7 +79,7 @@ if (!$loged_in)
$GLOBALS['egw']->preferences->account_id = $user;
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
$cal_prefs = &$GLOBALS['egw_info']['user']['preferences']['calendar'];
$loged_in = !empty($cal_prefs['freebusy']) &&
$logged_in = !empty($cal_prefs['freebusy']) &&
(empty($cal_prefs['freebusy_pw']) || $cal_prefs['freebusy_pw'] == $_GET['password']);
}
else
@ -86,18 +97,18 @@ if (!$loged_in)
}
if (array_key_exists($domain, $GLOBALS['egw_domain']))
{
$_POST['login'] = $authname;
$_POST['login'] = $authuser;
$_REQUEST['domain'] = $domain;
$GLOBALS['egw_info']['server']['default_domain'] = $domain;
$GLOBALS['egw_info']['user']['domain'] = $domain;
$GLOBALS['egw_info']['flags']['currentapp'] = 'login';
$GLOBALS['egw_info']['flags']['noapi'] = false;
$loged_in = $GLOBALS['egw']->session->create($authuser, $password, 'text');
$logged_in = $GLOBALS['egw']->session->create($authuser, $password, 'text');
session_unset();
session_destroy();
}
}
if (!$loged_in)
if (!$logged_in)
{
fail_exit(lang("freebusy: unknown user '%1', or not available for unauthenticated users!", $_GET['user']));
}

View File

@ -1204,7 +1204,7 @@ class calendar_so
*/
private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query,$users_raw)
{
if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','rpc.php','xmlrpc.php','/activesync/index.php')) ||
if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','freebusy.php','/activesync/index.php')) ||
!in_array($GLOBALS['egw_info']['flags']['currentapp'],array('calendar','home')))
{
return; // disable integration for GroupDAV, SyncML, ...