X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/federatedfilesharing/lib/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ protected function getCleanOrigin() {
protected function translateUid($uid) {
// FIXME this should be a method in the user management instead
// Move to a helper instead of C&P meanwhile?
$handled = false;
// the $handled var will be sent as reference so the listeners can use it as a flag
// in order to know if the event has been processed already or not.
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$uid]
['uid' => &$uid, 'hasBeenHandled' => &$handled]
);
return $uid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@ public function createShare() {
}
// FIXME this should be a method in the user management instead
\OCP\Util::writeLog('federatedfilesharing', 'shareWith before, ' . $shareWith, \OCP\Util::DEBUG);
$handled = false;
// the $handled var will be sent as reference so the listeners can use it as a flag
// in order to know if the event has been processed already or not.
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$shareWith]
['uid' => &$shareWith, 'hasBeenHandled' => &$handled]
);
\OCP\Util::writeLog('federatedfilesharing', 'shareWith after, ' . $shareWith, \OCP\Util::DEBUG);
if (!$this->userManager->userExists($shareWith)) {
Expand Down
10 changes: 10 additions & 0 deletions changelog/unreleased/39105
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Bugfix: Prevent unneeded call to LDAP during login with local users

Previously, when the user_ldap app was enabled, any login with a local user
would check the LDAP server for that user even though it shouldn't be needed.

Now, such call won't happen if it has been handled by a different component.
In particular, login with a local user won't trigger that request to LDAP.

https://github.com/owncloud/core/pull/39105
https://github.com/owncloud/user_ldap/pull/675
8 changes: 6 additions & 2 deletions lib/private/Share/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,19 @@ public static function isSameUserOnSameServer($user1, $server1, $user2, $server2

if (\rtrim($normalizedServer1, '/') === \rtrim($normalizedServer2, '/')) {
// FIXME this should be a method in the user management instead
$user1Handled = false;
$user2Handled = false;
// the $user1Handled and $user2Handled vars will be sent as reference so the listeners
// can use it as a flag in order to know if the event has been processed already or not.
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$user1]
['uid' => &$user1, 'hasBeenHandled' => &$user1Handled]
);
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$user2]
['uid' => &$user2, 'hasBeenHandled' => &$user2Handled]
);

if ($user1 === $user2) {
Expand Down
6 changes: 6 additions & 0 deletions lib/private/User/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,19 @@ public static function preLoginNameUsedAsUserName($param) {
throw new \Exception('key uid is expected to be set in $param');
}

if (isset($param['hasBeenHandled']) && $param['hasBeenHandled']) {
// if the event has been handled already, ignore it
return;
}

$backends = \OC::$server->getUserManager()->getBackends();
foreach ($backends as $backend) {
if ($backend instanceof Database) {
/** @var \OC\User\Database $backend */
$uid = $backend->loginName2UserName($param['uid']);
if ($uid !== false) {
$param['uid'] = $uid;
$param['hasBeenHandled'] = true; // mark the event as handled
return;
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/private/User/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,13 @@ private function isTokenAuthEnforced() {
}

protected function isTwoFactorEnforced($username) {
$handled = false;
// the $handled var will be sent as reference so the listeners can use it as a flag
// in order to know if the event has been processed already or not.
Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$username]
['uid' => &$username, 'hasBeenHandled' => &$handled]
);
$user = $this->manager->get($username);
if ($user === null) {
Expand Down
X Tutup