feat(legacy): remove db allowed_cors_origins preference (#2095)

- Remove after deprecation in eb8e7b3415
This commit is contained in:
Jonas L 2022-10-11 13:38:31 +02:00 committed by GitHub
parent e54c8d22e1
commit cff98f2d23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 60 deletions

View File

@ -0,0 +1,26 @@
# pylint: disable=invalid-name
from django.db import migrations
from ._migrations import legacy_migration_factory
UP = """
delete from cc_pref
where "keystr" = 'allowed_cors_urls';
"""
DOWN = """"""
class Migration(migrations.Migration):
dependencies = [
("legacy", "0042_remove_stream_preferences"),
]
operations = [
migrations.RunPython(
code=legacy_migration_factory(
target="43",
sql=UP,
)
)
]

View File

@ -1,2 +1,2 @@
# The schema version is defined using the migration file prefix number
LEGACY_SCHEMA_VERSION = "42"
LEGACY_SCHEMA_VERSION = "43"

View File

@ -27,27 +27,6 @@ class CORSHelper
*/
public static function getAllowedOrigins($request)
{
$config = Config::getConfig();
return array_merge(
$config['allowedCorsOrigins'],
self::getDatabaseAllowedOrigins()
);
}
/**
* Get database allowed origins.
*
* @return array
*/
private static function getDatabaseAllowedOrigins()
{
return array_map(
'trim',
explode(
PHP_EOL,
Application_Model_Preference::GetAllowedCorsUrls()
)
);
return Config::get('general.allowed_cors_origins');
}
}

View File

@ -47,7 +47,6 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetIntroPlaylist($values['introPlaylistSelect']);
Application_Model_Preference::SetOutroPlaylist($values['outroPlaylistSelect']);
Application_Model_Preference::SetAllow3rdPartyApi($values['thirdPartyApi']);
Application_Model_Preference::SetAllowedCorsUrls($values['allowedCorsUrls']);
Application_Model_Preference::SetDefaultLocale($values['locale']);
Application_Model_Preference::SetWeekStartDay($values['weekStartDay']);
Application_Model_Preference::setRadioPageDisplayLoginButton($values['radioPageLoginButton']);

View File

@ -171,13 +171,6 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
]);
$this->addElement($third_party_api);
$allowedCorsUrlsValue = Application_Model_Preference::GetAllowedCorsUrls();
$allowedCorsUrls = new Zend_Form_Element_Textarea('allowedCorsUrls');
$allowedCorsUrls->setLabel(_('Allowed CORS URLs (DEPRECATED)'));
$allowedCorsUrls->setDescription(_('Remote URLs that are allowed to access this LibreTime instance in a browser. One URL per line. (DEPRECATED: Allowed CORS origins configuration moved to the configuration file.)'));
$allowedCorsUrls->setValue($allowedCorsUrlsValue);
$this->addElement($allowedCorsUrls);
$locale = new Zend_Form_Element_Select('locale');
$locale->setLabel(_('Default Language'));
$locale->setMultiOptions(Application_Model_Locale::getLocales());

View File

@ -1514,34 +1514,6 @@ class Application_Model_Preference
self::setValue('station_podcast_privacy', $value);
}
/**
* Getter for CORS URLs.
*
* @return string
*/
public static function GetAllowedCorsUrls()
{
return self::getValue('allowed_cors_urls');
}
/**
* Setter for CORS URLs.
*
* @param string $value
*/
public static function SetAllowedCorsUrls($value)
{
// Trim and strip trailing slash for each entry
$value = implode(PHP_EOL, array_map(
function ($v) {
return rtrim(trim($v), '/');
},
explode(PHP_EOL, $value)
));
self::setValue('allowed_cors_urls', $value);
}
/**
* Getter for feature preview mode.
*

View File

@ -44,7 +44,6 @@
<?php echo $this->element->getElement('featurePreviewMode')->render() ?>
<?php echo $this->element->getElement('thirdPartyApi')->render() ?>
<?php echo $this->element->getElement('allowedCorsUrls')->render() ?>
<?php echo $this->element->getElement('radioPageLoginButton')->renderViewHelper() ?>
<?php echo $this->element->getElement('radioPageLoginButton')->renderLabel() ?>