Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Diagnostics cache checks #3027

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/Actions/Diagnostics/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Actions\Diagnostics\Pipes\Checks\AdminUserExistsCheck;
use App\Actions\Diagnostics\Pipes\Checks\AppUrlMatchCheck;
use App\Actions\Diagnostics\Pipes\Checks\BasicPermissionCheck;
use App\Actions\Diagnostics\Pipes\Checks\CachePasswordCheck;
use App\Actions\Diagnostics\Pipes\Checks\ConfigSanityCheck;
use App\Actions\Diagnostics\Pipes\Checks\CountSizeVariantsCheck;
use App\Actions\Diagnostics\Pipes\Checks\DBIntegrityCheck;
Expand Down Expand Up @@ -54,6 +55,7 @@ class Errors
SmallMediumExistsCheck::class,
PlaceholderExistsCheck::class,
CountSizeVariantsCheck::class,
CachePasswordCheck::class,
SupporterCheck::class,
];

Expand Down
38 changes: 38 additions & 0 deletions app/Actions/Diagnostics/Pipes/Checks/CachePasswordCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* SPDX-License-Identifier: MIT
* Copyright (c) 2017-2018 Tobias Reich
* Copyright (c) 2018-2025 LycheeOrg.
*/

namespace App\Actions\Diagnostics\Pipes\Checks;

use App\Constants\AccessPermissionConstants as APC;
use App\Contracts\DiagnosticPipe;
use App\DTO\DiagnosticData;
use App\Models\Configs;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

/**
* We check wether the config is set to use Cache and if there are password sets for albums.
*/
class CachePasswordCheck implements DiagnosticPipe
{
/**
* {@inheritDoc}
*/
public function handle(array &$data, \Closure $next): array
{
if (!Schema::hasTable('configs')) {
return $next($data);
}

if (Configs::getValueAsBool('cache_enabled') && DB::table(APC::ACCESS_PERMISSIONS)->whereNotNull('password')->count() > 0) {
$data[] = DiagnosticData::warn('Response cache is enabled and some albums are password protected.', self::class, ['Due to response caching, unlocking those albums will reveal their content to other annonymous users.']);
}

return $next($data);
}
}
3 changes: 3 additions & 0 deletions app/Http/Resources/Rights/AlbumRightsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use App\Contracts\Models\AbstractAlbum;
use App\Models\Album;
use App\Models\Configs;
use App\Policies\AlbumPolicy;
use Illuminate\Support\Facades\Gate;
use Spatie\LaravelData\Data;
Expand All @@ -27,6 +28,7 @@ class AlbumRightsResource extends Data
public bool $can_delete = false;
public bool $can_transfer = false;
public bool $can_access_original = false;
public bool $can_pasword_protect = false;

/**
* Given an album, returns the access rights associated to it.
Expand All @@ -42,5 +44,6 @@ public function __construct(?AbstractAlbum $abstractAlbum)
$this->can_delete = Gate::check(AlbumPolicy::CAN_DELETE, [AbstractAlbum::class, $abstractAlbum]);
$this->can_transfer = Gate::check(AlbumPolicy::CAN_TRANSFER, [AbstractAlbum::class, $abstractAlbum]);
$this->can_access_original = Gate::check(AlbumPolicy::CAN_ACCESS_FULL_PHOTO, [AbstractAlbum::class, $abstractAlbum]);
$this->can_pasword_protect = !Configs::getValueAsBool('cache_enabled');
}
}
1 change: 1 addition & 0 deletions lang/cz/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/cz/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/de/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/de/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/el/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/el/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/en/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/es/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/es/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/fr/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/fr/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/hu/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/hu/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/it/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/it/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/ja/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/ja/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/nl/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/nl/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/no/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/no/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/pl/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/pl/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/pt/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/pt/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/ru/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
2 changes: 2 additions & 0 deletions lang/ru/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'language' => 'Language used by Lychee',
'nsfw_album_visibility' => 'Make Sensitive albums visible by default.',
'nsfw_album_explanation' => 'If the album is public, it is still accessible, just hidden from the view and <b>can be revealed by pressing <kbd>H</kbd></b>.',
'cache_enabled' => 'Enable caching of responses.',
'cache_enabled_details' => 'This will significantly speed up the response time of Lychee.<br> <i class="pi pi-exclamation-triangle text-warning-600 mr-2"></i>If you are using password protected albums, you should not enable this.',
],
'lychee_se' => [
'header' => 'Lychee <span class="text-primary-emphasis">SE</span>',
Expand Down
1 change: 1 addition & 0 deletions lang/sk/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'password' => 'Password',
'password_prot' => 'Password protected',
'password_prot_expl' => 'Anonymous users need a shared password to access this album.',
'password_prop_not_compatible' => 'Response cache is conflicting with this setting.<br>Due to response caching, unlocking this album will<br>also reveal its content to other annonymous users.',
'nsfw' => 'Sensitive',
'nsfw_expl' => 'Album contains sensitive content.',
'visibility_updated' => 'Visibility updated.',
Expand Down
Loading