mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
commit
64631c7233
4 changed files with 135 additions and 129 deletions
|
@ -67,7 +67,7 @@ ADMIN_DOMAIN="${APP_DOMAIN}"
|
||||||
# @default "false"
|
# @default "false"
|
||||||
# @see https://docs.pixelfed.org/technical-documentation/config/#config_cache
|
# @see https://docs.pixelfed.org/technical-documentation/config/#config_cache
|
||||||
# @dottie/validate required,boolean
|
# @dottie/validate required,boolean
|
||||||
ENABLE_CONFIG_CACHE="false"
|
ENABLE_CONFIG_CACHE="true"
|
||||||
|
|
||||||
# Enable/disable new local account registrations.
|
# Enable/disable new local account registrations.
|
||||||
#
|
#
|
||||||
|
|
|
@ -8,7 +8,7 @@ OPEN_REGISTRATION="false"
|
||||||
ENFORCE_EMAIL_VERIFICATION="false"
|
ENFORCE_EMAIL_VERIFICATION="false"
|
||||||
PF_MAX_USERS="1000"
|
PF_MAX_USERS="1000"
|
||||||
OAUTH_ENABLED="true"
|
OAUTH_ENABLED="true"
|
||||||
ENABLE_CONFIG_CACHE=false
|
ENABLE_CONFIG_CACHE=true
|
||||||
|
|
||||||
# Media Configuration
|
# Media Configuration
|
||||||
PF_OPTIMIZE_IMAGES="true"
|
PF_OPTIMIZE_IMAGES="true"
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.12.0...dev)
|
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.12.0...dev)
|
||||||
|
|
||||||
### Updates
|
### Updates
|
||||||
|
- Update ApiV1Dot1Controller, fix in app registration bug that prevents proper auth flow due to missing oauth scopes ([cbf996c9](https://github.com/pixelfed/pixelfed/commit/cbf996c9))
|
||||||
|
- Update ConfigCacheService, fix database race condition and fallback to file config and enable by default ([60a62b59](https://github.com/pixelfed/pixelfed/commit/60a62b59))
|
||||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||||
|
|
||||||
## [v0.12.0 (2024-04-29)](https://github.com/pixelfed/pixelfed/compare/v0.11.13...v0.12.0)
|
## [v0.12.0 (2024-04-29)](https://github.com/pixelfed/pixelfed/compare/v0.11.13...v0.12.0)
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Services;
|
||||||
|
|
||||||
use App\Models\ConfigCache as ConfigCacheModel;
|
use App\Models\ConfigCache as ConfigCacheModel;
|
||||||
use Cache;
|
use Cache;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
|
||||||
class ConfigCacheService
|
class ConfigCacheService
|
||||||
{
|
{
|
||||||
|
@ -25,156 +26,159 @@ class ConfigCacheService
|
||||||
return config($key);
|
return config($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Cache::remember($cacheKey, $ttl, function () use ($key) {
|
try {
|
||||||
|
return Cache::remember($cacheKey, $ttl, function () use ($key) {
|
||||||
|
$allowed = [
|
||||||
|
'app.name',
|
||||||
|
'app.short_description',
|
||||||
|
'app.description',
|
||||||
|
'app.rules',
|
||||||
|
|
||||||
$allowed = [
|
'pixelfed.max_photo_size',
|
||||||
'app.name',
|
'pixelfed.max_album_length',
|
||||||
'app.short_description',
|
'pixelfed.image_quality',
|
||||||
'app.description',
|
'pixelfed.media_types',
|
||||||
'app.rules',
|
|
||||||
|
|
||||||
'pixelfed.max_photo_size',
|
'pixelfed.open_registration',
|
||||||
'pixelfed.max_album_length',
|
'federation.activitypub.enabled',
|
||||||
'pixelfed.image_quality',
|
'instance.stories.enabled',
|
||||||
'pixelfed.media_types',
|
'pixelfed.oauth_enabled',
|
||||||
|
'pixelfed.import.instagram.enabled',
|
||||||
|
'pixelfed.bouncer.enabled',
|
||||||
|
|
||||||
'pixelfed.open_registration',
|
'pixelfed.enforce_email_verification',
|
||||||
'federation.activitypub.enabled',
|
'pixelfed.max_account_size',
|
||||||
'instance.stories.enabled',
|
'pixelfed.enforce_account_limit',
|
||||||
'pixelfed.oauth_enabled',
|
|
||||||
'pixelfed.import.instagram.enabled',
|
|
||||||
'pixelfed.bouncer.enabled',
|
|
||||||
|
|
||||||
'pixelfed.enforce_email_verification',
|
'uikit.custom.css',
|
||||||
'pixelfed.max_account_size',
|
'uikit.custom.js',
|
||||||
'pixelfed.enforce_account_limit',
|
'uikit.show_custom.css',
|
||||||
|
'uikit.show_custom.js',
|
||||||
|
'about.title',
|
||||||
|
|
||||||
'uikit.custom.css',
|
'pixelfed.cloud_storage',
|
||||||
'uikit.custom.js',
|
|
||||||
'uikit.show_custom.css',
|
|
||||||
'uikit.show_custom.js',
|
|
||||||
'about.title',
|
|
||||||
|
|
||||||
'pixelfed.cloud_storage',
|
'account.autofollow',
|
||||||
|
'account.autofollow_usernames',
|
||||||
|
'config.discover.features',
|
||||||
|
|
||||||
'account.autofollow',
|
'instance.has_legal_notice',
|
||||||
'account.autofollow_usernames',
|
'instance.avatar.local_to_cloud',
|
||||||
'config.discover.features',
|
|
||||||
|
|
||||||
'instance.has_legal_notice',
|
'pixelfed.directory',
|
||||||
'instance.avatar.local_to_cloud',
|
'app.banner_image',
|
||||||
|
'pixelfed.directory.submission-key',
|
||||||
|
'pixelfed.directory.submission-ts',
|
||||||
|
'pixelfed.directory.has_submitted',
|
||||||
|
'pixelfed.directory.latest_response',
|
||||||
|
'pixelfed.directory.is_synced',
|
||||||
|
'pixelfed.directory.testimonials',
|
||||||
|
|
||||||
'pixelfed.directory',
|
'instance.landing.show_directory',
|
||||||
'app.banner_image',
|
'instance.landing.show_explore',
|
||||||
'pixelfed.directory.submission-key',
|
'instance.admin.pid',
|
||||||
'pixelfed.directory.submission-ts',
|
'instance.banner.blurhash',
|
||||||
'pixelfed.directory.has_submitted',
|
|
||||||
'pixelfed.directory.latest_response',
|
|
||||||
'pixelfed.directory.is_synced',
|
|
||||||
'pixelfed.directory.testimonials',
|
|
||||||
|
|
||||||
'instance.landing.show_directory',
|
'autospam.nlp.enabled',
|
||||||
'instance.landing.show_explore',
|
|
||||||
'instance.admin.pid',
|
|
||||||
'instance.banner.blurhash',
|
|
||||||
|
|
||||||
'autospam.nlp.enabled',
|
'instance.curated_registration.enabled',
|
||||||
|
|
||||||
'instance.curated_registration.enabled',
|
'federation.migration',
|
||||||
|
|
||||||
'federation.migration',
|
'pixelfed.max_caption_length',
|
||||||
|
'pixelfed.max_bio_length',
|
||||||
|
'pixelfed.max_name_length',
|
||||||
|
'pixelfed.min_password_length',
|
||||||
|
'pixelfed.max_avatar_size',
|
||||||
|
'pixelfed.max_altext_length',
|
||||||
|
'pixelfed.allow_app_registration',
|
||||||
|
'pixelfed.app_registration_rate_limit_attempts',
|
||||||
|
'pixelfed.app_registration_rate_limit_decay',
|
||||||
|
'pixelfed.app_registration_confirm_rate_limit_attempts',
|
||||||
|
'pixelfed.app_registration_confirm_rate_limit_decay',
|
||||||
|
'instance.embed.profile',
|
||||||
|
'instance.embed.post',
|
||||||
|
|
||||||
'pixelfed.max_caption_length',
|
'captcha.enabled',
|
||||||
'pixelfed.max_bio_length',
|
'captcha.secret',
|
||||||
'pixelfed.max_name_length',
|
'captcha.sitekey',
|
||||||
'pixelfed.min_password_length',
|
'captcha.active.login',
|
||||||
'pixelfed.max_avatar_size',
|
'captcha.active.register',
|
||||||
'pixelfed.max_altext_length',
|
'captcha.triggers.login.enabled',
|
||||||
'pixelfed.allow_app_registration',
|
'captcha.triggers.login.attempts',
|
||||||
'pixelfed.app_registration_rate_limit_attempts',
|
'federation.custom_emoji.enabled',
|
||||||
'pixelfed.app_registration_rate_limit_decay',
|
|
||||||
'pixelfed.app_registration_confirm_rate_limit_attempts',
|
|
||||||
'pixelfed.app_registration_confirm_rate_limit_decay',
|
|
||||||
'instance.embed.profile',
|
|
||||||
'instance.embed.post',
|
|
||||||
|
|
||||||
'captcha.enabled',
|
'pixelfed.optimize_image',
|
||||||
'captcha.secret',
|
'pixelfed.optimize_video',
|
||||||
'captcha.sitekey',
|
'pixelfed.max_collection_length',
|
||||||
'captcha.active.login',
|
'media.delete_local_after_cloud',
|
||||||
'captcha.active.register',
|
'instance.user_filters.max_user_blocks',
|
||||||
'captcha.triggers.login.enabled',
|
'instance.user_filters.max_user_mutes',
|
||||||
'captcha.triggers.login.attempts',
|
'instance.user_filters.max_domain_blocks',
|
||||||
'federation.custom_emoji.enabled',
|
|
||||||
|
|
||||||
'pixelfed.optimize_image',
|
'filesystems.disks.s3.key',
|
||||||
'pixelfed.optimize_video',
|
'filesystems.disks.s3.secret',
|
||||||
'pixelfed.max_collection_length',
|
'filesystems.disks.s3.region',
|
||||||
'media.delete_local_after_cloud',
|
'filesystems.disks.s3.bucket',
|
||||||
'instance.user_filters.max_user_blocks',
|
'filesystems.disks.s3.visibility',
|
||||||
'instance.user_filters.max_user_mutes',
|
'filesystems.disks.s3.url',
|
||||||
'instance.user_filters.max_domain_blocks',
|
'filesystems.disks.s3.endpoint',
|
||||||
|
'filesystems.disks.s3.use_path_style_endpoint',
|
||||||
|
|
||||||
'filesystems.disks.s3.key',
|
'filesystems.disks.spaces.key',
|
||||||
'filesystems.disks.s3.secret',
|
'filesystems.disks.spaces.secret',
|
||||||
'filesystems.disks.s3.region',
|
'filesystems.disks.spaces.region',
|
||||||
'filesystems.disks.s3.bucket',
|
'filesystems.disks.spaces.bucket',
|
||||||
'filesystems.disks.s3.visibility',
|
'filesystems.disks.spaces.visibility',
|
||||||
'filesystems.disks.s3.url',
|
'filesystems.disks.spaces.url',
|
||||||
'filesystems.disks.s3.endpoint',
|
'filesystems.disks.spaces.endpoint',
|
||||||
'filesystems.disks.s3.use_path_style_endpoint',
|
'filesystems.disks.spaces.use_path_style_endpoint',
|
||||||
|
// 'system.user_mode'
|
||||||
|
];
|
||||||
|
|
||||||
'filesystems.disks.spaces.key',
|
if (! config('instance.enable_cc')) {
|
||||||
'filesystems.disks.spaces.secret',
|
return config($key);
|
||||||
'filesystems.disks.spaces.region',
|
|
||||||
'filesystems.disks.spaces.bucket',
|
|
||||||
'filesystems.disks.spaces.visibility',
|
|
||||||
'filesystems.disks.spaces.url',
|
|
||||||
'filesystems.disks.spaces.endpoint',
|
|
||||||
'filesystems.disks.spaces.use_path_style_endpoint',
|
|
||||||
// 'system.user_mode'
|
|
||||||
];
|
|
||||||
|
|
||||||
if (! config('instance.enable_cc')) {
|
|
||||||
return config($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! in_array($key, $allowed)) {
|
|
||||||
return config($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
$protect = false;
|
|
||||||
$protected = null;
|
|
||||||
if(in_array($key, self::PROTECTED_KEYS)) {
|
|
||||||
$protect = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$v = config($key);
|
|
||||||
$c = ConfigCacheModel::where('k', $key)->first();
|
|
||||||
|
|
||||||
if ($c) {
|
|
||||||
if($protect) {
|
|
||||||
return decrypt($c->v) ?? config($key);
|
|
||||||
} else {
|
|
||||||
return $c->v ?? config($key);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (! $v) {
|
if (! in_array($key, $allowed)) {
|
||||||
return;
|
return config($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($protect && $v) {
|
$protect = false;
|
||||||
$protected = encrypt($v);
|
$protected = null;
|
||||||
}
|
if(in_array($key, self::PROTECTED_KEYS)) {
|
||||||
|
$protect = true;
|
||||||
|
}
|
||||||
|
|
||||||
$cc = new ConfigCacheModel;
|
$v = config($key);
|
||||||
$cc->k = $key;
|
$c = ConfigCacheModel::where('k', $key)->first();
|
||||||
$cc->v = $protect ? $protected : $v;
|
|
||||||
$cc->save();
|
|
||||||
|
|
||||||
return $v;
|
if ($c) {
|
||||||
});
|
if($protect) {
|
||||||
|
return decrypt($c->v) ?? config($key);
|
||||||
|
} else {
|
||||||
|
return $c->v ?? config($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $v) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($protect && $v) {
|
||||||
|
$protected = encrypt($v);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cc = new ConfigCacheModel;
|
||||||
|
$cc->k = $key;
|
||||||
|
$cc->v = $protect ? $protected : $v;
|
||||||
|
$cc->save();
|
||||||
|
|
||||||
|
return $v;
|
||||||
|
});
|
||||||
|
} catch (Exception | QueryException $e) {
|
||||||
|
return config($key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function put($key, $val)
|
public static function put($key, $val)
|
||||||
|
|
Loading…
Reference in a new issue