Add version of Sabre lib, add log on login errors.

Add compatibility with twoauth
This commit is contained in:
Laurent Destailleur 2019-08-20 13:26:56 +02:00
parent 5dee861f7d
commit 54234e011f
2 changed files with 21 additions and 5 deletions

View File

@ -68,7 +68,6 @@ $head=dav_admin_prepare_head();
dol_fiche_head($head, 'webdav', '', -1, 'action');
if ($action == 'edit')
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -76,7 +75,7 @@ if ($action == 'edit')
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val)
{
@ -112,7 +111,7 @@ if ($action == 'edit')
else
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val)
{
@ -177,6 +176,13 @@ if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
}
print $message;
print '<br><br><br>';
require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
$version = Sabre\DAV\Version::VERSION;
print '<span class="opacitymedium">'.$langs->trans("BaseOnSabeDavVersion").' : '.$version.'</span>';
// End of page
llxFooter();
$db->close();

View File

@ -72,15 +72,25 @@ $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $p
global $dolibarr_main_authentication;
if (empty($user->login))
{
dol_syslog("Failed to authenticate to DAV, login is not provided", LOG_WARNING);
return false;
}
if ($user->socid > 0)
{
dol_syslog("Failed to authenticate to DAV, use is an external user", LOG_WARNING);
return false;
}
if ($user->login != $username)
{
dol_syslog("Failed to authenticate to DAV, login does not match the login of loaded user", LOG_WARNING);
return false;
}
// Authentication mode
if (empty($dolibarr_main_authentication))
$dolibarr_main_authentication='http,dolibarr';
if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='dolibarr';
$dolibarr_main_authentication = preg_replace('/twoauth/', 'dolibarr', $dolibarr_main_authentication);
$authmode = explode(',', $dolibarr_main_authentication);
$entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1));