Commit 04e7c3a1 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1329 Revert IBackend->Logon() modifications and remove the

$impersonatedUsername to keep backward compatibility. This needs to be
redone in ZP-1351.

Released under the Affero GNU General Public License (AGPL) version 3.
parent f8018de9
...@@ -305,7 +305,7 @@ class ZPushAutodiscover { ...@@ -305,7 +305,7 @@ class ZPushAutodiscover {
$username = Utils::GetLocalPartFromEmail($username); $username = Utils::GetLocalPartFromEmail($username);
} }
$backend = ZPush::GetBackend(); $backend = ZPush::GetBackend();
if ($backend->Logon($username, false, "", $_SERVER['PHP_AUTH_PW']) == false) { if ($backend->Logon($username, "", $_SERVER['PHP_AUTH_PW']) == false) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ZPushAutodiscover->getLogin(): Login failed for user '%s' from IP %s.", $username, $_SERVER["REMOTE_ADDR"])); ZLog::Write(LOGLEVEL_ERROR, sprintf("ZPushAutodiscover->getLogin(): Login failed for user '%s' from IP %s.", $username, $_SERVER["REMOTE_ADDR"]));
throw new AuthenticationRequiredException("Access denied. Username or password incorrect."); throw new AuthenticationRequiredException("Access denied. Username or password incorrect.");
} }
......
...@@ -57,7 +57,7 @@ class BackendCalDAV extends BackendDiff { ...@@ -57,7 +57,7 @@ class BackendCalDAV extends BackendDiff {
* Login to the CalDAV backend * Login to the CalDAV backend
* @see IBackend::Logon() * @see IBackend::Logon()
*/ */
public function Logon($username, $impersonatedUsername, $domain, $password) { public function Logon($username, $domain, $password) {
$this->_caldav_path = str_replace('%u', $username, CALDAV_PATH); $this->_caldav_path = str_replace('%u', $username, CALDAV_PATH);
$url = sprintf("%s://%s:%d%s", CALDAV_PROTOCOL, CALDAV_SERVER, CALDAV_PORT, $this->_caldav_path); $url = sprintf("%s://%s:%d%s", CALDAV_PROTOCOL, CALDAV_SERVER, CALDAV_PORT, $this->_caldav_path);
$this->_caldav = new CalDAVClient($url, $username, $password); $this->_caldav = new CalDAVClient($url, $username, $password);
......
...@@ -76,7 +76,7 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider { ...@@ -76,7 +76,7 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
* @access public * @access public
* @return boolean * @return boolean
*/ */
public function Logon($username, $impersonatedUsername, $domain, $password) { public function Logon($username, $domain, $password) {
$this->url = CARDDAV_PROTOCOL . '://' . CARDDAV_SERVER . ':' . CARDDAV_PORT . str_replace("%d", $domain, str_replace("%u", $username, CARDDAV_PATH)); $this->url = CARDDAV_PROTOCOL . '://' . CARDDAV_SERVER . ':' . CARDDAV_PORT . str_replace("%d", $domain, str_replace("%u", $username, CARDDAV_PATH));
$this->default_url = CARDDAV_PROTOCOL . '://' . CARDDAV_SERVER . ':' . CARDDAV_PORT . str_replace("%d", $domain, str_replace("%u", $username, CARDDAV_DEFAULT_PATH)); $this->default_url = CARDDAV_PROTOCOL . '://' . CARDDAV_SERVER . ':' . CARDDAV_PORT . str_replace("%d", $domain, str_replace("%u", $username, CARDDAV_DEFAULT_PATH));
if (defined('CARDDAV_GAL_PATH')) { if (defined('CARDDAV_GAL_PATH')) {
......
...@@ -63,14 +63,13 @@ class BackendCombined extends Backend implements ISearchProvider { ...@@ -63,14 +63,13 @@ class BackendCombined extends Backend implements ISearchProvider {
* Authenticates the user on each backend * Authenticates the user on each backend
* *
* @param string $username * @param string $username
* @param string $impersonatedUsername
* @param string $domain * @param string $domain
* @param string $password * @param string $password
* *
* @access public * @access public
* @return boolean * @return boolean
*/ */
public function Logon($username, $impersonatedUsername, $domain, $password) { public function Logon($username, $domain, $password) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->Logon('%s', '%s',***))", $username, $domain)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->Logon('%s', '%s',***))", $username, $domain));
if(!is_array($this->backends)){ if(!is_array($this->backends)){
return false; return false;
...@@ -91,8 +90,7 @@ class BackendCombined extends Backend implements ISearchProvider { ...@@ -91,8 +90,7 @@ class BackendCombined extends Backend implements ISearchProvider {
if(isset($this->config['backends'][$i]['users'][$username]['domain'])) if(isset($this->config['backends'][$i]['users'][$username]['domain']))
$d = $this->config['backends'][$i]['users'][$username]['domain']; $d = $this->config['backends'][$i]['users'][$username]['domain'];
} }
// TODO: impersonation is not supported by Combined if($this->backends[$i]->Logon($u, $d, $p) == false){
if($this->backends[$i]->Logon($u, false, $d, $p) == false){
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->Logon() failed on %s ", $this->config['backends'][$i]['name'])); ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->Logon() failed on %s ", $this->config['backends'][$i]['name']));
return false; return false;
} }
......
...@@ -78,7 +78,6 @@ class BackendIMAP extends BackendDiff implements ISearchProvider { ...@@ -78,7 +78,6 @@ class BackendIMAP extends BackendDiff implements ISearchProvider {
* Authenticates the user * Authenticates the user
* *
* @param string $username * @param string $username
* @param string $impersonatedUsername
* @param string $domain * @param string $domain
* @param string $password * @param string $password
* *
...@@ -86,7 +85,7 @@ class BackendIMAP extends BackendDiff implements ISearchProvider { ...@@ -86,7 +85,7 @@ class BackendIMAP extends BackendDiff implements ISearchProvider {
* @return boolean * @return boolean
* @throws FatalException if php-imap module can not be found * @throws FatalException if php-imap module can not be found
*/ */
public function Logon($username, $impersonatedUsername, $domain, $password) { public function Logon($username, $domain, $password) {
$this->wasteID = false; $this->wasteID = false;
$this->sentID = false; $this->sentID = false;
$this->server = "{" . IMAP_SERVER . ":" . IMAP_PORT . "/imap" . IMAP_OPTIONS . "}"; $this->server = "{" . IMAP_SERVER . ":" . IMAP_PORT . "/imap" . IMAP_OPTIONS . "}";
......
...@@ -28,7 +28,7 @@ function create_calendar_dav($data) { ...@@ -28,7 +28,7 @@ function create_calendar_dav($data) {
if (defined('IMAP_MEETING_USE_CALDAV') && IMAP_MEETING_USE_CALDAV) { if (defined('IMAP_MEETING_USE_CALDAV') && IMAP_MEETING_USE_CALDAV) {
$caldav = new BackendCalDAV(); $caldav = new BackendCalDAV();
if ($caldav->Logon(Request::GetAuthUser(), Request::GetImpersonatedUser(), Request::GetAuthDomain(), Request::GetAuthPassword())) { if ($caldav->Logon(Request::GetAuthUser(), Request::GetAuthDomain(), Request::GetAuthPassword())) {
$etag = $caldav->CreateUpdateCalendar($data); $etag = $caldav->CreateUpdateCalendar($data);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->create_calendar_dav(): Calendar created with etag '%s' and data <%s>", $etag, $data)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->create_calendar_dav(): Calendar created with etag '%s' and data <%s>", $etag, $data));
$caldav->Logoff(); $caldav->Logoff();
...@@ -48,7 +48,7 @@ function delete_calendar_dav($uid) { ...@@ -48,7 +48,7 @@ function delete_calendar_dav($uid) {
else { else {
if (defined('IMAP_MEETING_USE_CALDAV') && IMAP_MEETING_USE_CALDAV) { if (defined('IMAP_MEETING_USE_CALDAV') && IMAP_MEETING_USE_CALDAV) {
$caldav = new BackendCalDAV(); $caldav = new BackendCalDAV();
if ($caldav->Logon(Request::GetAuthUser(), Request::GetImpersonatedUser(), Request::GetAuthDomain(), Request::GetAuthPassword())) { if ($caldav->Logon(Request::GetAuthUser(), Request::GetAuthDomain(), Request::GetAuthPassword())) {
$events = $caldav->FindCalendar($uid); $events = $caldav->FindCalendar($uid);
if (count($events) == 1) { if (count($events) == 1) {
$href = $events[0]["href"]; $href = $events[0]["href"];
...@@ -85,7 +85,7 @@ function update_calendar_attendee($uid, $mailto, $status) { ...@@ -85,7 +85,7 @@ function update_calendar_attendee($uid, $mailto, $status) {
else { else {
if (defined('IMAP_MEETING_USE_CALDAV') && IMAP_MEETING_USE_CALDAV) { if (defined('IMAP_MEETING_USE_CALDAV') && IMAP_MEETING_USE_CALDAV) {
$caldav = new BackendCalDAV(); $caldav = new BackendCalDAV();
if ($caldav->Logon(Request::GetAuthUser(), Request::GetImpersonatedUser(), Request::GetAuthDomain(), Request::GetAuthPassword())) { if ($caldav->Logon(Request::GetAuthUser(), Request::GetAuthDomain(), Request::GetAuthPassword())) {
$events = $caldav->FindCalendar($uid); $events = $caldav->FindCalendar($uid);
if (count($events) == 1) { if (count($events) == 1) {
$href = $events[0]["href"]; $href = $events[0]["href"];
......
...@@ -132,7 +132,6 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -132,7 +132,6 @@ class BackendKopano implements IBackend, ISearchProvider {
* Authenticates the user with the configured Kopano server * Authenticates the user with the configured Kopano server
* *
* @param string $username * @param string $username
* @param string $impersonatedUsername
* @param string $domain * @param string $domain
* @param string $password * @param string $password
* *
...@@ -140,15 +139,16 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -140,15 +139,16 @@ class BackendKopano implements IBackend, ISearchProvider {
* @return boolean * @return boolean
* @throws AuthenticationRequiredException * @throws AuthenticationRequiredException
*/ */
public function Logon($user, $impersonatedUsername, $domain, $pass) { public function Logon($user, $domain, $pass) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("KopanoBackend->Logon(): Trying to authenticate user '%s'..", $user)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("KopanoBackend->Logon(): Trying to authenticate user '%s'..", $user));
$this->mainUser = strtolower($user); $this->mainUser = strtolower($user);
$this->impersonateUser = $impersonatedUsername; // TODO the impersonated user should be passed directly to IBackend->Logon() - ZP-1351
$this->impersonateUser = Request::GetImpersonatedUser();
// check if we are impersonating someone // check if we are impersonating someone
// $defaultUser will be used for $this->defaultStore // $defaultUser will be used for $this->defaultStore
if ($impersonatedUsername !== false) { if ($this->impersonateUser !== false) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("KopanoBackend->Logon(): Impersonation active - authenticating: '%s' - impersonating '%s'", $this->mainUser, $this->impersonateUser)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("KopanoBackend->Logon(): Impersonation active - authenticating: '%s' - impersonating '%s'", $this->mainUser, $this->impersonateUser));
$defaultUser = $this->impersonateUser; $defaultUser = $this->impersonateUser;
} }
......
...@@ -35,7 +35,7 @@ class BackendLDAP extends BackendDiff { ...@@ -35,7 +35,7 @@ class BackendLDAP extends BackendDiff {
private $ldap_link; private $ldap_link;
private $user; private $user;
public function Logon($username, $impersonatedUsername, $domain, $password) { public function Logon($username, $domain, $password) {
$this->user = $username; $this->user = $username;
$user_dn = str_replace('%u', $username, LDAP_USER_DN); $user_dn = str_replace('%u', $username, LDAP_USER_DN);
$this->ldap_link = ldap_connect(LDAP_SERVER, LDAP_SERVER_PORT); $this->ldap_link = ldap_connect(LDAP_SERVER, LDAP_SERVER_PORT);
......
...@@ -56,7 +56,7 @@ class BackendMaildir extends BackendDiff { ...@@ -56,7 +56,7 @@ class BackendMaildir extends BackendDiff {
* @access public * @access public
* @return boolean * @return boolean
*/ */
public function Logon($username, $impersonatedUsername, $domain, $password) { public function Logon($username, $domain, $password) {
return true; return true;
} }
......
...@@ -44,7 +44,7 @@ class BackendVCardDir extends BackendDiff { ...@@ -44,7 +44,7 @@ class BackendVCardDir extends BackendDiff {
* @access public * @access public
* @return boolean * @return boolean
*/ */
public function Logon($username, $impersonatedUsername, $domain, $password) { public function Logon($username, $domain, $password) {
return true; return true;
} }
......
...@@ -86,7 +86,7 @@ abstract class Backend implements IBackend { ...@@ -86,7 +86,7 @@ abstract class Backend implements IBackend {
/********************************************************************* /*********************************************************************
* Methods to be implemented * Methods to be implemented
* *
* public function Logon($username, $impersonatedUsername, $domain, $password); * public function Logon($username, $domain, $password);
* public function Setup($store, $checkACLonly = false, $folderid = false, $readonly = false); * public function Setup($store, $checkACLonly = false, $folderid = false, $readonly = false);
* public function Logoff(); * public function Logoff();
* public function GetHierarchy(); * public function GetHierarchy();
......
...@@ -60,7 +60,6 @@ interface IBackend { ...@@ -60,7 +60,6 @@ interface IBackend {
* Authenticates the user * Authenticates the user
* *
* @param string $username * @param string $username
* @param string $impersonatedUsername
* @param string $domain * @param string $domain
* @param string $password * @param string $password
* *
...@@ -68,7 +67,7 @@ interface IBackend { ...@@ -68,7 +67,7 @@ interface IBackend {
* @return boolean * @return boolean
* @throws FatalException e.g. some required libraries are unavailable * @throws FatalException e.g. some required libraries are unavailable
*/ */
public function Logon($username, $impersonatedUsername, $domain, $password); public function Logon($username, $domain, $password);
/** /**
* Setup the backend to work on a specific store or checks ACLs there. * Setup the backend to work on a specific store or checks ACLs there.
......
...@@ -65,7 +65,7 @@ abstract class RequestProcessor { ...@@ -65,7 +65,7 @@ abstract class RequestProcessor {
} }
$backend = ZPush::GetBackend(); $backend = ZPush::GetBackend();
if($backend->Logon(Request::GetAuthUser(), Request::GetImpersonatedUser(), Request::GetAuthDomain(), Request::GetAuthPassword()) == false) if($backend->Logon(Request::GetAuthUser(), Request::GetAuthDomain(), Request::GetAuthPassword()) == false)
throw new AuthenticationRequiredException("Access denied. Username or password incorrect"); throw new AuthenticationRequiredException("Access denied. Username or password incorrect");
// mark this request as "authenticated" // mark this request as "authenticated"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment