Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bollu <cyrpub@bollu.be>2022-02-05 22:49:17 +0300
committerCyrille Bollu <cyrpub@bollu.be>2022-04-11 22:58:24 +0300
commitc6a5c07041d2e5d20771409aede8b755d28372ac (patch)
tree71051efd25c16bed5a419eb1670477f1f5471933 /apps/files_sharing/lib/Controller/ShareAPIController.php
parent60f946aba5862102a81100b09e26b37b6d59a3fa (diff)
Adds a "Request password" button to the public share authentication page for shares
of type TYPE_EMAIL, when the "video verification" checkbox isn't checked. Users accessing non-anonymous public shares (TYPE_EMAIL shares) can now request a temporary password themselves. - Creates a migration step for the files_sharing app to add the 'password_expiration_time' attribute to the oc_shares table. - Makes share temporary passwords' expiration time configurable via a system value. - Adds a system config value to allow permanent share passwords -Fixes a typo in a comment in apps/files_sharing/src/components/SharingEntryLink.vue See https://github.com/nextcloud/server/issues/31005 Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
Diffstat (limited to 'apps/files_sharing/lib/Controller/ShareAPIController.php')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 069cba42bb6..d324af3e9f2 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -279,6 +279,7 @@ class ShareAPIController extends OCSController {
} elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
$result['share_with'] = $share->getSharedWith();
$result['password'] = $share->getPassword();
+ $result['password_expiration_time'] = $share->getPasswordExpirationTime();
$result['send_password_by_talk'] = $share->getSendPasswordByTalk();
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
$result['token'] = $share->getToken();
@@ -570,6 +571,10 @@ class ShareAPIController extends OCSController {
// Set password
if ($password !== '') {
$share->setPassword($password);
+ // Shares shared by email have temporary passwords by default
+ if ($shareType === IShare::TYPE_EMAIL) {
+ $this->setSharePasswordExpirationTime($share);
+ }
}
// Only share by mail have a recipient
@@ -1177,6 +1182,9 @@ class ShareAPIController extends OCSController {
$share->setPassword(null);
} elseif ($password !== null) {
$share->setPassword($password);
+ if ($share->getShareType() === IShare::TYPE_EMAIL) {
+ $this->setSharePasswordExpirationTime($share);
+ }
}
if ($label !== null) {
@@ -1514,6 +1522,35 @@ class ShareAPIController extends OCSController {
}
/**
+ * Set the share's password expiration time
+ */
+ private function setSharePasswordExpirationTime(IShare $share): void {
+ if ($this->config->getSystemValue('allow_mail_share_permanent_password')) {
+ // Sets password expiration date to NULL
+ $share->setPasswordExpirationTime();
+ return;
+ }
+ // Sets password expiration date
+ $expirationTime = null;
+ try {
+ $now = new \DateTime();
+ $expirationInterval = $this->config->getSystemValue('share_temporary_password_expiration_interval');
+ if ($expirationInterval === '' || is_null($expirationInterval)) {
+ $expirationInterval = 'P0DT15M';
+ }
+ $expirationTime = $now->add(new \DateInterval($expirationInterval));
+ } catch (\Exception $e) {
+ // Catches invalid format for system value 'share_temporary_password_expiration_interval'
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'The \'share_temporary_password_expiration_interval\' system setting does not respect the DateInterval::__construct() format. Setting it to \'P0DT15M\''
+ ]);
+ $expirationTime = $now->add(new \DateInterval('P0DT15M'));
+ } finally {
+ $share->setPasswordExpirationTime($expirationTime);
+ }
+ }
+
+ /**
* Since we have multiple providers but the OCS Share API v1 does
* not support this we need to check all backends.
*