From d48d701493bb06849e5e3cf43e769e71032f0ad0 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 10 Aug 2022 15:54:13 +0530 Subject: [PATCH 1/5] performance fix, replace alt domain suffix in client login --- Dockerfile | 3 ++- patches/019-client-login-with-alt-domain.patch | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 patches/019-client-login-with-alt-domain.patch diff --git a/Dockerfile b/Dockerfile index 5581b82e..9b51eda3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ ARG ECLOUD_LAUNCHER_JOB_ID="345049" ARG GOOGLE_INTEGRATION_VERSION="1.0.6" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" -RUN sed -i 's/22,2,9,1/22,2,9,2/' ${BASE_DIR}/version.php +RUN sed -i 's/22,2,9,1/22,2,9,3/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images @@ -127,6 +127,7 @@ RUN patch -u ${BASE_DIR}/lib/private/legacy/OC_Helper.php -i ${TMP_PATCH_DIR}/01 RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/015-email-mail-template.patch RUN patch -u ${BASE_DIR}/core/templates/layout.guest.php -i ${TMP_PATCH_DIR}/016-login-screen.patch RUN patch -u ${BASE_DIR}/core/Command/User/Setting.php -i ${TMP_PATCH_DIR}/018-occ-user-setting.patch +RUN patch -u ${BASE_DIR}/lib/private/User/Session.php -i ${TMP_PATCH_DIR}/019-client-login-with-alt-domain.patch RUN rm -rf ${TMP_PATCH_DIR} # autocomplete leak tweak apps frontend with sed, disable group suggestion diff --git a/patches/019-client-login-with-alt-domain.patch b/patches/019-client-login-with-alt-domain.patch new file mode 100644 index 00000000..4bb14806 --- /dev/null +++ b/patches/019-client-login-with-alt-domain.patch @@ -0,0 +1,15 @@ +--- ./lib/private/User/Session.php 2022-08-10 15:39:33.131890282 +0530 ++++ ./lib/private/User/Session-new.php 2022-08-10 15:48:23.236165783 +0530 +@@ -456,7 +456,11 @@ + if (!$isTokenPassword && $this->isTwoFactorEnforced($user)) { + throw new PasswordLoginForbiddenException(); + } +- ++ ++ $altDomain = $this->config->getSystemValue('alt_mail_domain', ''); ++ $altDomainSuffix = !empty($altDomain) ? '@' . $altDomain : ''; ++ $user = str_replace($altDomainSuffix, '', $user); ++ + // Try to login with this username and password + if (!$this->login($user, $password)) { + -- GitLab From 6797b5183da2e4cc98a7a4216134c3b2b8018440 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 10 Aug 2022 15:58:03 +0530 Subject: [PATCH 2/5] Keep in same patch --- patches/002-login-without-domain.patch | 16 ++++++++++++++++ patches/019-client-login-with-alt-domain.patch | 15 --------------- 2 files changed, 16 insertions(+), 15 deletions(-) delete mode 100644 patches/019-client-login-with-alt-domain.patch diff --git a/patches/002-login-without-domain.patch b/patches/002-login-without-domain.patch index faefb4a7..3c2fa7ed 100644 --- a/patches/002-login-without-domain.patch +++ b/patches/002-login-without-domain.patch @@ -66,3 +66,19 @@ diff --git ./core/Controller/LoginController.php ./core/Controller/LoginControll Util::emitHook( '\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', + +--- ./lib/private/User/Session.php 2022-08-10 15:39:33.131890282 +0530 ++++ ./lib/private/User/Session-new.php 2022-08-10 15:48:23.236165783 +0530 +@@ -456,7 +456,11 @@ + if (!$isTokenPassword && $this->isTwoFactorEnforced($user)) { + throw new PasswordLoginForbiddenException(); + } +- ++ ++ $altDomain = $this->config->getSystemValue('alt_mail_domain', ''); ++ $altDomainSuffix = !empty($altDomain) ? '@' . $altDomain : ''; ++ $user = str_replace($altDomainSuffix, '', $user); ++ + // Try to login with this username and password + if (!$this->login($user, $password)) { + diff --git a/patches/019-client-login-with-alt-domain.patch b/patches/019-client-login-with-alt-domain.patch deleted file mode 100644 index 4bb14806..00000000 --- a/patches/019-client-login-with-alt-domain.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- ./lib/private/User/Session.php 2022-08-10 15:39:33.131890282 +0530 -+++ ./lib/private/User/Session-new.php 2022-08-10 15:48:23.236165783 +0530 -@@ -456,7 +456,11 @@ - if (!$isTokenPassword && $this->isTwoFactorEnforced($user)) { - throw new PasswordLoginForbiddenException(); - } -- -+ -+ $altDomain = $this->config->getSystemValue('alt_mail_domain', ''); -+ $altDomainSuffix = !empty($altDomain) ? '@' . $altDomain : ''; -+ $user = str_replace($altDomainSuffix, '', $user); -+ - // Try to login with this username and password - if (!$this->login($user, $password)) { - -- GitLab From 738a831bb7d4f665fee021accb4b6ee132d60f88 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 10 Aug 2022 16:04:17 +0530 Subject: [PATCH 3/5] Remove 019 --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9b51eda3..0aedb16a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -127,7 +127,6 @@ RUN patch -u ${BASE_DIR}/lib/private/legacy/OC_Helper.php -i ${TMP_PATCH_DIR}/01 RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/015-email-mail-template.patch RUN patch -u ${BASE_DIR}/core/templates/layout.guest.php -i ${TMP_PATCH_DIR}/016-login-screen.patch RUN patch -u ${BASE_DIR}/core/Command/User/Setting.php -i ${TMP_PATCH_DIR}/018-occ-user-setting.patch -RUN patch -u ${BASE_DIR}/lib/private/User/Session.php -i ${TMP_PATCH_DIR}/019-client-login-with-alt-domain.patch RUN rm -rf ${TMP_PATCH_DIR} # autocomplete leak tweak apps frontend with sed, disable group suggestion -- GitLab From ed4bd07a0747044bc8c6c321e07e4fed49cd7b3f Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 10 Aug 2022 16:11:08 +0530 Subject: [PATCH 4/5] Don't bump version number --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0aedb16a..5581b82e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ ARG ECLOUD_LAUNCHER_JOB_ID="345049" ARG GOOGLE_INTEGRATION_VERSION="1.0.6" ARG LDAP_WRITE_SUPPORT_VERSION="1.4.0" -RUN sed -i 's/22,2,9,1/22,2,9,3/' ${BASE_DIR}/version.php +RUN sed -i 's/22,2,9,1/22,2,9,2/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images -- GitLab From 2575f04fe3912d042f0327ce6c4e1b44b1b7cdce Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 10 Aug 2022 17:20:26 +0530 Subject: [PATCH 5/5] Patch location updated --- patches/002-login-without-domain.patch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/patches/002-login-without-domain.patch b/patches/002-login-without-domain.patch index 3c2fa7ed..ff52c4c0 100644 --- a/patches/002-login-without-domain.patch +++ b/patches/002-login-without-domain.patch @@ -69,16 +69,16 @@ diff --git ./core/Controller/LoginController.php ./core/Controller/LoginControll --- ./lib/private/User/Session.php 2022-08-10 15:39:33.131890282 +0530 +++ ./lib/private/User/Session-new.php 2022-08-10 15:48:23.236165783 +0530 -@@ -456,7 +456,11 @@ - if (!$isTokenPassword && $this->isTwoFactorEnforced($user)) { - throw new PasswordLoginForbiddenException(); - } +@@ -438,7 +438,11 @@ + IRequest $request, + OC\Security\Bruteforce\Throttler $throttler) { + $currentDelay = $throttler->sleepDelay($request->getRemoteAddress(), 'login'); - + + $altDomain = $this->config->getSystemValue('alt_mail_domain', ''); + $altDomainSuffix = !empty($altDomain) ? '@' . $altDomain : ''; + $user = str_replace($altDomainSuffix, '', $user); + - // Try to login with this username and password - if (!$this->login($user, $password)) { - + if ($this->manager instanceof PublicEmitter) { + $this->manager->emit('\OC\User', 'preLogin', [$user, $password]); + } -- GitLab