From d19071edacf278e3f12ee4b10c741eb7f5617c50 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Sun, 10 Dec 2023 23:17:34 -0800 Subject: [PATCH 1/8] Verification Token patch to add expiry date as arugment --- Dockerfile | 2 ++ patches/033-verification-token-public.patch | 11 +++++++++++ patches/034-verification-token-private.patch | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 patches/033-verification-token-public.patch create mode 100644 patches/034-verification-token-private.patch diff --git a/Dockerfile b/Dockerfile index c5c90752..4b9b6544 100644 --- a/Dockerfile +++ b/Dockerfile @@ -211,6 +211,8 @@ RUN patch -u ${BASE_DIR}/lib/private/User/Manager.php -i ${TMP_PATCH_DIR}/025-op RUN patch -u ${BASE_DIR}/apps/dav/lib/Connector/Sabre/Principal.php -i ${TMP_PATCH_DIR}/027-displayname-user-leak-dav.patch RUN patch -u ${BASE_DIR}/apps/dav/lib/HookManager.php -i ${TMP_PATCH_DIR}/028-default-task-calendar.patch RUN patch -u ${BASE_DIR}/apps/provisioning_api/lib/Controller/UsersController.php -i ${TMP_PATCH_DIR}/029-restrict-user-to-change-primary-email.patch +RUN patch -u ${BASE_DIR}/lib/public/Security/VerificationToken/IVerificationToken.php -i ${TMP_PATCH_DIR}/033-verification-token-public.patch +RUN patch -u ${BASE_DIR}/lib/private/Security/VerificationToken/VerificationToken.php -i ${TMP_PATCH_DIR}/034-verification-token-private.patch RUN rm -rf ${TMP_PATCH_DIR} RUN curl -fsSL -o ldap_write_support.tar.gz \ diff --git a/patches/033-verification-token-public.patch b/patches/033-verification-token-public.patch new file mode 100644 index 00000000..ce01cc9d --- /dev/null +++ b/patches/033-verification-token-public.patch @@ -0,0 +1,11 @@ +--- lib/public/Security/VerificationToken/IVerificationToken.php 2023-05-17 00:32:43 ++++ lib/public/Security/VerificationToken/IVerificationToken-new.php 2023-12-10 22:14:17 +@@ -51,7 +51,7 @@ + /** + * @since 23.0.0 + */ +- public function create(IUser $user, string $subject, string $passwordPrefix = ''): string; ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', string $expiryToken = ''): string; + + /** + * Deletes the token identified by the provided parameters diff --git a/patches/034-verification-token-private.patch b/patches/034-verification-token-private.patch new file mode 100644 index 00000000..f54776c4 --- /dev/null +++ b/patches/034-verification-token-private.patch @@ -0,0 +1,20 @@ +--- lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 ++++ lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-10 23:11:32 +@@ -107,7 +107,7 @@ + } + } + +- public function create(IUser $user, string $subject, string $passwordPrefix = ''): string { ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', string $expiryToken = ''): string { + $token = $this->secureRandom->generate( + 21, + ISecureRandom::CHAR_DIGITS. +@@ -121,7 +121,7 @@ + 'userId' => $user->getUID(), + 'subject' => $subject, + 'pp' => $passwordPrefix, +- 'notBefore' => $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period ++ 'notBefore' => ($expiryToken !== '') ? $expiryToken : $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period + ]); + $this->jobList->add(CleanUpJob::class, $jobArgs); + -- GitLab From 5224a62b43424bd66ce6f01b1200a72fab80e1d2 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Sun, 10 Dec 2023 23:20:40 -0800 Subject: [PATCH 2/8] renamed argument name --- patches/033-verification-token-public.patch | 6 +++--- patches/034-verification-token-private.patch | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/patches/033-verification-token-public.patch b/patches/033-verification-token-public.patch index ce01cc9d..0ff2cb44 100644 --- a/patches/033-verification-token-public.patch +++ b/patches/033-verification-token-public.patch @@ -1,11 +1,11 @@ ---- lib/public/Security/VerificationToken/IVerificationToken.php 2023-05-17 00:32:43 -+++ lib/public/Security/VerificationToken/IVerificationToken-new.php 2023-12-10 22:14:17 +--- /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/public/Security/VerificationToken/IVerificationToken.php 2023-05-17 00:32:43 ++++ /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/public/Security/VerificationToken/IVerificationToken-new.php 2023-12-10 23:19:31 @@ -51,7 +51,7 @@ /** * @since 23.0.0 */ - public function create(IUser $user, string $subject, string $passwordPrefix = ''): string; -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', string $expiryToken = ''): string; ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', string $expirationTime = ''): string; /** * Deletes the token identified by the provided parameters diff --git a/patches/034-verification-token-private.patch b/patches/034-verification-token-private.patch index f54776c4..c78b596b 100644 --- a/patches/034-verification-token-private.patch +++ b/patches/034-verification-token-private.patch @@ -1,11 +1,11 @@ ---- lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 -+++ lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-10 23:11:32 +--- /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 ++++ /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-10 23:19:20 @@ -107,7 +107,7 @@ } } - public function create(IUser $user, string $subject, string $passwordPrefix = ''): string { -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', string $expiryToken = ''): string { ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', string $expirationTime = ''): string { $token = $this->secureRandom->generate( 21, ISecureRandom::CHAR_DIGITS. @@ -14,7 +14,7 @@ 'subject' => $subject, 'pp' => $passwordPrefix, - 'notBefore' => $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period -+ 'notBefore' => ($expiryToken !== '') ? $expiryToken : $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period ++ 'notBefore' => ($expirationTime !== '') ? $expirationTime : $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period ]); $this->jobList->add(CleanUpJob::class, $jobArgs); -- GitLab From 35e59e58741b26fae4f0d9efa9cf30867925132d Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Sun, 10 Dec 2023 23:36:59 -0800 Subject: [PATCH 3/8] changes --- patches/033-verification-token-public.patch | 4 ++-- patches/034-verification-token-private.patch | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/033-verification-token-public.patch b/patches/033-verification-token-public.patch index 0ff2cb44..55159cab 100644 --- a/patches/033-verification-token-public.patch +++ b/patches/033-verification-token-public.patch @@ -1,5 +1,5 @@ ---- /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/public/Security/VerificationToken/IVerificationToken.php 2023-05-17 00:32:43 -+++ /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/public/Security/VerificationToken/IVerificationToken-new.php 2023-12-10 23:19:31 +--- lib/public/Security/VerificationToken/IVerificationToken.php 2023-05-17 00:32:43 ++++ lib/public/Security/VerificationToken/IVerificationToken-new.php 2023-12-10 23:19:31 @@ -51,7 +51,7 @@ /** * @since 23.0.0 diff --git a/patches/034-verification-token-private.patch b/patches/034-verification-token-private.patch index c78b596b..0ae5ece9 100644 --- a/patches/034-verification-token-private.patch +++ b/patches/034-verification-token-private.patch @@ -1,5 +1,5 @@ ---- /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 -+++ /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-10 23:19:20 +--- lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 ++++ lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-10 23:19:20 @@ -107,7 +107,7 @@ } } -- GitLab From d6181c80f7afd3de96238513911583af87336d67 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Mon, 11 Dec 2023 00:05:30 -0800 Subject: [PATCH 4/8] int --- patches/033-verification-token-public.patch | 2 +- patches/034-verification-token-private.patch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/033-verification-token-public.patch b/patches/033-verification-token-public.patch index 55159cab..a6b92ac3 100644 --- a/patches/033-verification-token-public.patch +++ b/patches/033-verification-token-public.patch @@ -5,7 +5,7 @@ * @since 23.0.0 */ - public function create(IUser $user, string $subject, string $passwordPrefix = ''): string; -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', string $expirationTime = ''): string; ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = ''): string; /** * Deletes the token identified by the provided parameters diff --git a/patches/034-verification-token-private.patch b/patches/034-verification-token-private.patch index 0ae5ece9..3472d3c1 100644 --- a/patches/034-verification-token-private.patch +++ b/patches/034-verification-token-private.patch @@ -5,7 +5,7 @@ } - public function create(IUser $user, string $subject, string $passwordPrefix = ''): string { -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', string $expirationTime = ''): string { ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = ''): string { $token = $this->secureRandom->generate( 21, ISecureRandom::CHAR_DIGITS. -- GitLab From 1a8ab37a638546b643ef7d34647afe788a1c745e Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Mon, 11 Dec 2023 00:12:09 -0800 Subject: [PATCH 5/8] int --- patches/033-verification-token-public.patch | 2 +- patches/034-verification-token-private.patch | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/033-verification-token-public.patch b/patches/033-verification-token-public.patch index a6b92ac3..d8b532dd 100644 --- a/patches/033-verification-token-public.patch +++ b/patches/033-verification-token-public.patch @@ -5,7 +5,7 @@ * @since 23.0.0 */ - public function create(IUser $user, string $subject, string $passwordPrefix = ''): string; -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = ''): string; ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = 0): string; /** * Deletes the token identified by the provided parameters diff --git a/patches/034-verification-token-private.patch b/patches/034-verification-token-private.patch index 3472d3c1..e748614e 100644 --- a/patches/034-verification-token-private.patch +++ b/patches/034-verification-token-private.patch @@ -5,7 +5,7 @@ } - public function create(IUser $user, string $subject, string $passwordPrefix = ''): string { -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = ''): string { ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = 0): string { $token = $this->secureRandom->generate( 21, ISecureRandom::CHAR_DIGITS. @@ -14,7 +14,7 @@ 'subject' => $subject, 'pp' => $passwordPrefix, - 'notBefore' => $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period -+ 'notBefore' => ($expirationTime !== '') ? $expirationTime : $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period ++ 'notBefore' => ($expirationTime > 0) ? $expirationTime : $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period ]); $this->jobList->add(CleanUpJob::class, $jobArgs); -- GitLab From c3631ab553d20842420665ce358c6145a9b99e04 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Mon, 11 Dec 2023 23:29:57 -0800 Subject: [PATCH 6/8] change in patch --- ...ate.patch => 033-verification-token-private.patch} | 8 ++++---- patches/033-verification-token-public.patch | 11 ----------- 2 files changed, 4 insertions(+), 15 deletions(-) rename patches/{034-verification-token-private.patch => 033-verification-token-private.patch} (51%) delete mode 100644 patches/033-verification-token-public.patch diff --git a/patches/034-verification-token-private.patch b/patches/033-verification-token-private.patch similarity index 51% rename from patches/034-verification-token-private.patch rename to patches/033-verification-token-private.patch index e748614e..4408a736 100644 --- a/patches/034-verification-token-private.patch +++ b/patches/033-verification-token-private.patch @@ -1,11 +1,11 @@ ---- lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 -+++ lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-10 23:19:20 +--- /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 ++++ /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-11 23:29:24 @@ -107,7 +107,7 @@ } } - public function create(IUser $user, string $subject, string $passwordPrefix = ''): string { -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = 0): string { ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = self::TOKEN_LIFETIME): string { $token = $this->secureRandom->generate( 21, ISecureRandom::CHAR_DIGITS. @@ -14,7 +14,7 @@ 'subject' => $subject, 'pp' => $passwordPrefix, - 'notBefore' => $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period -+ 'notBefore' => ($expirationTime > 0) ? $expirationTime : $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period ++ 'notBefore' => $this->timeFactory->getTime() + $expirationTime * 2, // multiply to provide a grace period ]); $this->jobList->add(CleanUpJob::class, $jobArgs); diff --git a/patches/033-verification-token-public.patch b/patches/033-verification-token-public.patch deleted file mode 100644 index d8b532dd..00000000 --- a/patches/033-verification-token-public.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- lib/public/Security/VerificationToken/IVerificationToken.php 2023-05-17 00:32:43 -+++ lib/public/Security/VerificationToken/IVerificationToken-new.php 2023-12-10 23:19:31 -@@ -51,7 +51,7 @@ - /** - * @since 23.0.0 - */ -- public function create(IUser $user, string $subject, string $passwordPrefix = ''): string; -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = 0): string; - - /** - * Deletes the token identified by the provided parameters -- GitLab From af29b8efc4abc5fe275c705916c3ec7a55e6cebb Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Mon, 11 Dec 2023 23:30:58 -0800 Subject: [PATCH 7/8] change in patch --- Dockerfile | 3 +-- patches/033-verification-token-private.patch | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b9b6544..65536ece 100644 --- a/Dockerfile +++ b/Dockerfile @@ -211,8 +211,7 @@ RUN patch -u ${BASE_DIR}/lib/private/User/Manager.php -i ${TMP_PATCH_DIR}/025-op RUN patch -u ${BASE_DIR}/apps/dav/lib/Connector/Sabre/Principal.php -i ${TMP_PATCH_DIR}/027-displayname-user-leak-dav.patch RUN patch -u ${BASE_DIR}/apps/dav/lib/HookManager.php -i ${TMP_PATCH_DIR}/028-default-task-calendar.patch RUN patch -u ${BASE_DIR}/apps/provisioning_api/lib/Controller/UsersController.php -i ${TMP_PATCH_DIR}/029-restrict-user-to-change-primary-email.patch -RUN patch -u ${BASE_DIR}/lib/public/Security/VerificationToken/IVerificationToken.php -i ${TMP_PATCH_DIR}/033-verification-token-public.patch -RUN patch -u ${BASE_DIR}/lib/private/Security/VerificationToken/VerificationToken.php -i ${TMP_PATCH_DIR}/034-verification-token-private.patch +RUN patch -u ${BASE_DIR}/lib/private/Security/VerificationToken/VerificationToken.php -i ${TMP_PATCH_DIR}/033-verification-token-private.patch RUN rm -rf ${TMP_PATCH_DIR} RUN curl -fsSL -o ldap_write_support.tar.gz \ diff --git a/patches/033-verification-token-private.patch b/patches/033-verification-token-private.patch index 4408a736..b89f811c 100644 --- a/patches/033-verification-token-private.patch +++ b/patches/033-verification-token-private.patch @@ -1,5 +1,5 @@ ---- /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 -+++ /Users/ronak/Desktop/murena/nextcloud/ecloud_dev_example/volumes/nextcloud/html/lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-11 23:29:24 +--- lib/private/Security/VerificationToken/VerificationToken.php 2023-12-10 23:05:06 ++++ lib/private/Security/VerificationToken/VerificationToken-new.php 2023-12-11 23:29:24 @@ -107,7 +107,7 @@ } } -- GitLab From 1d17b276e5aa6f7fd0c74ad3ccdb56a9c7a920a8 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Tue, 12 Dec 2023 05:34:33 -0800 Subject: [PATCH 8/8] change in argument --- patches/033-verification-token-private.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/033-verification-token-private.patch b/patches/033-verification-token-private.patch index b89f811c..12190696 100644 --- a/patches/033-verification-token-private.patch +++ b/patches/033-verification-token-private.patch @@ -5,7 +5,7 @@ } - public function create(IUser $user, string $subject, string $passwordPrefix = ''): string { -+ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = self::TOKEN_LIFETIME): string { ++ public function create(IUser $user, string $subject, string $passwordPrefix = '', int $expirationTime = self::TOKEN_LIFETIME * 2): string { $token = $this->secureRandom->generate( 21, ISecureRandom::CHAR_DIGITS. @@ -14,7 +14,7 @@ 'subject' => $subject, 'pp' => $passwordPrefix, - 'notBefore' => $this->timeFactory->getTime() + self::TOKEN_LIFETIME * 2, // multiply to provide a grace period -+ 'notBefore' => $this->timeFactory->getTime() + $expirationTime * 2, // multiply to provide a grace period ++ 'notBefore' => $this->timeFactory->getTime() + $expirationTime, // multiply to provide a grace period ]); $this->jobList->add(CleanUpJob::class, $jobArgs); -- GitLab