diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 27b79bee7dfa9..e417bc06f6ca8 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -275,6 +275,8 @@ public function testCreateShareLinkPublicUpload(array $appConfig, int $permissio public function testEnforceLinkPassword(): void { $password = md5(time()); $config = Server::get(IConfig::class); + $appConfig = Server::get(IAppConfig::class); + $appConfig->setValueBool('core', ConfigLexicon::SHARE_LINK_PASSWORD_DEFAULT, true); $config->setAppValue('core', 'shareapi_enforce_links_password', 'yes'); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); @@ -320,6 +322,7 @@ public function testEnforceLinkPassword(): void { $ocs->cleanup(); $config->setAppValue('core', 'shareapi_enforce_links_password', 'no'); + $appConfig->setValueBool('core', ConfigLexicon::SHARE_LINK_PASSWORD_DEFAULT, false); $this->addToAssertionCount(1); } diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php index 99b1712e38e9f..fe47dd420d03a 100644 --- a/apps/files_sharing/tests/CapabilitiesTest.php +++ b/apps/files_sharing/tests/CapabilitiesTest.php @@ -151,6 +151,7 @@ public function testLinkPassword(): void { ['core', 'shareapi_enforce_links_password_excluded_groups', '', ''], ]; $typedMap = [ + ['core', 'shareapi_enable_link_password_by_default', true], ['core', 'shareapi_enforce_links_password', true], ]; $result = $this->getResults($map, $typedMap); @@ -159,6 +160,22 @@ public function testLinkPassword(): void { $this->assertTrue($result['public']['password']['enforced']); } + public function testLinkPasswordEnforcedWithoutDefaultPrompt(): void { + $map = [ + ['core', 'shareapi_enabled', 'yes', 'yes'], + ['core', 'shareapi_allow_links', 'yes', 'yes'], + ['core', 'shareapi_enforce_links_password_excluded_groups', '', ''], + ]; + $typedMap = [ + ['core', 'shareapi_enable_link_password_by_default', false], + ['core', 'shareapi_enforce_links_password', true], + ]; + $result = $this->getResults($map, $typedMap); + $this->assertArrayHasKey('password', $result['public']); + $this->assertArrayHasKey('enforced', $result['public']['password']); + $this->assertFalse($result['public']['password']['enforced']); + } + public function testLinkNoPassword(): void { $map = [ ['core', 'shareapi_enabled', 'yes', 'yes'], diff --git a/apps/settings/lib/Settings/Admin/Sharing.php b/apps/settings/lib/Settings/Admin/Sharing.php index e560fce0b2bc6..3deb750451b92 100644 --- a/apps/settings/lib/Settings/Admin/Sharing.php +++ b/apps/settings/lib/Settings/Admin/Sharing.php @@ -60,7 +60,7 @@ public function getForm() { 'restrictUserEnumerationFullMatchDisplayname' => $this->shareManager->matchDisplayName(), 'restrictUserEnumerationFullMatchEmail' => $this->shareManager->matchEmail(), 'restrictUserEnumerationFullMatchIgnoreSecondDN' => $this->shareManager->ignoreSecondDisplayName(), - 'enforceLinksPassword' => $this->shareManager->shareApiLinkEnforcePassword(false), + 'enforceLinksPassword' => $this->appConfig->getValueBool('core', ConfigLexicon::SHARE_LINK_PASSWORD_ENFORCED), 'enforceLinksPasswordExcludedGroups' => json_decode($excludedPasswordGroups) ?? [], 'enforceLinksPasswordExcludedGroupsEnabled' => $this->config->getSystemValueBool('sharing.allow_disabled_password_enforcement_groups', false), 'onlyShareWithGroupMembers' => $this->shareManager->shareWithGroupMembersOnly(), diff --git a/apps/settings/src/components/AdminSettingsSharingForm.vue b/apps/settings/src/components/AdminSettingsSharingForm.vue index 89fa03525adfa..01914ad716028 100644 --- a/apps/settings/src/components/AdminSettingsSharingForm.vue +++ b/apps/settings/src/components/AdminSettingsSharingForm.vue @@ -59,15 +59,20 @@ {{ t('settings', 'Always ask for a password') }} - + {{ t('settings', 'Enforce password protection') }} -