Skip to content

Commit 7a9c04a

Browse files
committed
fix(sharing): Allow public share access for everyone
When a logged-in user accesses a public share link in the same browser, the system was incorrectly checking if that user's groups were excluded from creating link shares. This caused share not found errors for users in excluded groups, even though public shares should be accessible to anyone with the link. The group exclusion setting (`shareapi_allow_links_exclude_groups`) is intended to restrict share creation, not share access. Public shares are meant to be anonymous and accessible regardless of the viewer identity or group membership. Signed-off-by: nfebe <fenn25.fn@gmail.com>
1 parent 6fc190e commit 7a9c04a

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

lib/private/Share20/Manager.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ public function getShareByToken($token) {
14131413
}
14141414
$share = null;
14151415
try {
1416-
if ($this->shareApiAllowLinks()) {
1416+
if ($this->shareApiAllowLinks(checkGroupExclusion: false)) {
14171417
$provider = $this->factory->getProviderForType(IShare::TYPE_LINK);
14181418
$share = $provider->getShareByToken($token);
14191419
}
@@ -1742,19 +1742,22 @@ public function shareApiEnabled() {
17421742
/**
17431743
* Is public link sharing enabled
17441744
*
1745+
* @param bool $checkGroupExclusion Whether to check the current user's group exclusions
17451746
* @return bool
17461747
*/
1747-
public function shareApiAllowLinks() {
1748+
public function shareApiAllowLinks(bool $checkGroupExclusion = true) {
17481749
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
17491750
return false;
17501751
}
17511752

1752-
$user = $this->userSession->getUser();
1753-
if ($user) {
1754-
$excludedGroups = json_decode($this->config->getAppValue('core', 'shareapi_allow_links_exclude_groups', '[]'));
1755-
if ($excludedGroups) {
1756-
$userGroups = $this->groupManager->getUserGroupIds($user);
1757-
return !(bool)array_intersect($excludedGroups, $userGroups);
1753+
if ($checkGroupExclusion) {
1754+
$user = $this->userSession->getUser();
1755+
if ($user) {
1756+
$excludedGroups = json_decode($this->config->getAppValue('core', 'shareapi_allow_links_exclude_groups', '[]'));
1757+
if ($excludedGroups) {
1758+
$userGroups = $this->groupManager->getUserGroupIds($user);
1759+
return !(bool)array_intersect($excludedGroups, $userGroups);
1760+
}
17581761
}
17591762
}
17601763

0 commit comments

Comments
 (0)