Skip to content

Commit f021a29

Browse files
authored
Fix unexpected password propagation behaviour (#3927)
1 parent 219eb90 commit f021a29

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

app/Actions/Album/Unlock.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use App\Models\BaseAlbumImpl;
1414
use App\Models\Extensions\BaseAlbum;
1515
use App\Policies\AlbumPolicy;
16+
use App\Repositories\ConfigManager;
1617
use Illuminate\Support\Facades\Hash;
1718

1819
class Unlock
@@ -45,6 +46,9 @@ public function do(BaseAlbum $album, string $password): void
4546
return;
4647
}
4748
if (Hash::check($password, $album_password)) {
49+
$this->album_policy->unlock($album); // unlock the album
50+
51+
// propage the unlock to all albums with the same password
4852
$this->propagate($password);
4953

5054
return;
@@ -60,6 +64,12 @@ public function do(BaseAlbum $album, string $password): void
6064
*/
6165
private function propagate(string $password): void
6266
{
67+
// Only propagate if the option is enabled
68+
$config_manager = app(ConfigManager::class);
69+
if ($config_manager->getValueAsBool('enable_propagate_unlock_option') === false) {
70+
return;
71+
}
72+
6373
// We add all the albums that the password unlocks so that the
6474
// user is not repeatedly asked to enter the password as they
6575
// browse through the hierarchy. This should be safe as the
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* SPDX-License-Identifier: MIT
5+
* Copyright (c) 2017-2018 Tobias Reich
6+
* Copyright (c) 2018-2026 LycheeOrg.
7+
*/
8+
9+
use App\Models\Extensions\BaseConfigMigration;
10+
11+
return new class() extends BaseConfigMigration {
12+
public const MOD_GALLERY = 'Admin';
13+
14+
/**
15+
* @return array<int,array{key:string,value:string,is_secret:bool,cat:string,type_range:string,description:string,order?:int,not_on_docker?:bool,is_expert?:bool}>
16+
*/
17+
public function getConfigs(): array
18+
{
19+
return [
20+
[
21+
'key' => 'enable_propagate_unlock_option',
22+
'value' => '0',
23+
'cat' => self::MOD_GALLERY,
24+
'type_range' => self::BOOL,
25+
'description' => 'Enable unlock propagation.',
26+
'details' => 'When unlocking an album with password, also unlock all albums with that same password.<br><i class="pi pi-exclamation-triangle text-orange-500"></i> This can lead to confidentiality issues if different users share the same album password.',
27+
'is_secret' => false,
28+
'is_expert' => true,
29+
'order' => 25,
30+
'not_on_docker' => false,
31+
'level' => 0,
32+
],
33+
];
34+
}
35+
};

0 commit comments

Comments
 (0)